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.emit('contractsState', self.contractsState());
});

View File

@ -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) => {