refactor test deployment to not use engine directly

This commit is contained in:
Iuri Matias 2018-08-06 16:32:22 -04:00
parent 600d686342
commit 95c945c238
2 changed files with 13 additions and 14 deletions

View File

@ -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.on("deploy:contract:error", (_contract) => {
self.events.emit('contractsState', self.contractsState()); self.events.emit('contractsState', self.contractsState());
}); });

View File

@ -39,8 +39,7 @@ class Test {
this.firstRunConfig = true; this.firstRunConfig = true;
this.error = false; this.error = false;
this.contracts = {}; this.contracts = {};
this.builtContracts = {}; this.firstDeployment = true;
this.compiledContracts = {};
this.logsSubscription = null; this.logsSubscription = null;
this.needConfig = true; this.needConfig = true;
this.web3 = new Web3(); this.web3 = new Web3();
@ -236,25 +235,17 @@ class Test {
self.checkDeploymentOptions(options, next); self.checkDeploymentOptions(options, next);
}, },
function compileContracts(next) { function compileContracts(next) {
if (Object.keys(self.builtContracts).length > 0) { if (!self.firstDeployment) {
return next(); return next();
} }
console.info('Compiling contracts'.cyan); console.info('Compiling contracts'.cyan);
self.engine.events.request("contracts:build", false, (err) => { self.engine.events.request("contracts:build", false, (err) => {
self.builtContracts = cloneDeep(self.engine.contractsManager.contracts); self.firstDeployment = false;
let className; next(err);
for (className in self.builtContracts) {
self.builtContracts[className].dependencyCount = null;
}
self.compiledContracts = cloneDeep(self.engine.contractsManager.compiledContracts);
next();
}); });
}, },
function resetContracts(next) { function resetContracts(next) {
self.engine.contractsManager.contracts = cloneDeep(self.builtContracts); self.engine.events.request("contracts:reset:dependencies", next);
self.engine.contractsManager.compiledContracts = cloneDeep(self.compiledContracts);
self.engine.contractsManager.contractDependencies = {};
next();
}, },
function deploy(next) { function deploy(next) {
self._deploy(options, (err, accounts) => { self._deploy(options, (err, accounts) => {