only deploy configured contracts in the tests

This commit is contained in:
Iuri Matias 2018-03-11 08:28:03 -04:00
parent 83227beaa1
commit 6479bf816b
6 changed files with 16 additions and 23 deletions

View File

@ -15,6 +15,7 @@ class ContractsManager {
this.plugins = options.plugins;
this.contractDependencies = {};
this.gasLimit = options.gasLimit;
this.deployOnlyOnConfig = false;
}
build(done) {
@ -71,6 +72,10 @@ class ContractsManager {
for (className in self.contracts) {
contract = self.contracts[className];
contract.deploy = (contract.deploy === undefined) || contract.deploy;
if (self.deployOnlyOnConfig && !self.contractsConfig.contracts[className]) {
contract.deploy = false;
}
if (contract.code === "") {
self.logger.info("assuming " + className + " to be an interface");
contract.deploy = false;

View File

@ -16,6 +16,7 @@ class DeployManager {
this.contractsManager = options.contractsManager;
this.gasLimit = false;
this.fatalErrors = false;
this.deployOnlyOnConfig = false;
}
deployContracts(done) {
@ -29,6 +30,7 @@ class DeployManager {
async.waterfall([
function buildContracts(callback) {
self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor
self.contractsManager.build(callback);
},
function checkWeb3IsConnected(contractsManager, callback) {

View File

@ -79,6 +79,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
self.engine.deployManager.gasLimit = 6000000;
self.engine.contractsManager.gasLimit = 6000000;
self.engine.deployManager.fatalErrors = true;
self.engine.deployManager.deployOnlyOnConfig = true;
self.engine.deployManager.deployContracts(function(err, _result) {
if (err) {
callback(err);

View File

@ -8,29 +8,6 @@ contract("AnotherStorage", function() {
},
"AnotherStorage": {
args: ["$SimpleStorage"]
},
"Token": {
deploy: false,
args: [1000]
},
"MyToken": {
instanceOf: "Token"
},
"MyToken2": {
instanceOf: "Token",
args: [2000]
},
"ContractArgs": {
"args": {
"initialValue": 123,
"_addresses": ["$MyToken2", "$SimpleStorage"]
}
},
"SomeContract": {
"args": [
["$MyToken2", "$SimpleStorage"],
100
]
}
};
EmbarkSpec.deployAll(contractsConfig, () => { done() });

View File

@ -2,9 +2,13 @@ contract("Test", function() {
before(function(done) {
this.timeout(0);
var contractsConfig = {
"Test2": {
},
"Test": {
"gas": 2000000
},
"ZAMyLib": {
},
"ZAMyLib2": {
"deploy": true
},

View File

@ -10,6 +10,10 @@ describe("Token", function() {
//});
var contractsConfig = {
"ZAMyLib": {
},
"Token": {
},
"SimpleStorage": {
args: [100]
},