From 95c945c238fcae1031f60371947ed031035231ac Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 6 Aug 2018 16:32:22 -0400 Subject: [PATCH] refactor test deployment to not use engine directly --- lib/contracts/contracts.js | 8 ++++++++ lib/tests/test.js | 19 +++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 537088b79..8348668fb 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -43,6 +43,14 @@ class ContractsManager { }); }); + self.events.setCommandHandler("contracts:reset:dependencies", (cb) => { + for (let className in self.contracts) { + self.contracts[className].dependencyCount = null; + } + self.contractDependencies = {}; + cb(); + }); + self.events.on("deploy:contract:error", (_contract) => { self.events.emit('contractsState', self.contractsState()); }); diff --git a/lib/tests/test.js b/lib/tests/test.js index bf2e8c00c..381a8cbec 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -39,8 +39,7 @@ class Test { this.firstRunConfig = true; this.error = false; this.contracts = {}; - this.builtContracts = {}; - this.compiledContracts = {}; + this.firstDeployment = true; this.logsSubscription = null; this.needConfig = true; this.web3 = new Web3(); @@ -236,25 +235,17 @@ class Test { self.checkDeploymentOptions(options, next); }, function compileContracts(next) { - if (Object.keys(self.builtContracts).length > 0) { + if (!self.firstDeployment) { return next(); } console.info('Compiling contracts'.cyan); self.engine.events.request("contracts:build", false, (err) => { - self.builtContracts = cloneDeep(self.engine.contractsManager.contracts); - let className; - for (className in self.builtContracts) { - self.builtContracts[className].dependencyCount = null; - } - self.compiledContracts = cloneDeep(self.engine.contractsManager.compiledContracts); - next(); + self.firstDeployment = false; + next(err); }); }, function resetContracts(next) { - self.engine.contractsManager.contracts = cloneDeep(self.builtContracts); - self.engine.contractsManager.compiledContracts = cloneDeep(self.compiledContracts); - self.engine.contractsManager.contractDependencies = {}; - next(); + self.engine.events.request("contracts:reset:dependencies", next); }, function deploy(next) { self._deploy(options, (err, accounts) => {