mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-09 04:15:08 +00:00
only deploy configured contracts in the tests
This commit is contained in:
parent
83227beaa1
commit
6479bf816b
@ -15,6 +15,7 @@ class ContractsManager {
|
|||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
this.contractDependencies = {};
|
this.contractDependencies = {};
|
||||||
this.gasLimit = options.gasLimit;
|
this.gasLimit = options.gasLimit;
|
||||||
|
this.deployOnlyOnConfig = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
build(done) {
|
build(done) {
|
||||||
@ -71,6 +72,10 @@ class ContractsManager {
|
|||||||
for (className in self.contracts) {
|
for (className in self.contracts) {
|
||||||
contract = self.contracts[className];
|
contract = self.contracts[className];
|
||||||
contract.deploy = (contract.deploy === undefined) || contract.deploy;
|
contract.deploy = (contract.deploy === undefined) || contract.deploy;
|
||||||
|
if (self.deployOnlyOnConfig && !self.contractsConfig.contracts[className]) {
|
||||||
|
contract.deploy = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (contract.code === "") {
|
if (contract.code === "") {
|
||||||
self.logger.info("assuming " + className + " to be an interface");
|
self.logger.info("assuming " + className + " to be an interface");
|
||||||
contract.deploy = false;
|
contract.deploy = false;
|
||||||
|
@ -16,6 +16,7 @@ class DeployManager {
|
|||||||
this.contractsManager = options.contractsManager;
|
this.contractsManager = options.contractsManager;
|
||||||
this.gasLimit = false;
|
this.gasLimit = false;
|
||||||
this.fatalErrors = false;
|
this.fatalErrors = false;
|
||||||
|
this.deployOnlyOnConfig = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
deployContracts(done) {
|
deployContracts(done) {
|
||||||
@ -29,6 +30,7 @@ class DeployManager {
|
|||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function buildContracts(callback) {
|
function buildContracts(callback) {
|
||||||
|
self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor
|
||||||
self.contractsManager.build(callback);
|
self.contractsManager.build(callback);
|
||||||
},
|
},
|
||||||
function checkWeb3IsConnected(contractsManager, callback) {
|
function checkWeb3IsConnected(contractsManager, callback) {
|
||||||
|
@ -79,6 +79,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
|
|||||||
self.engine.deployManager.gasLimit = 6000000;
|
self.engine.deployManager.gasLimit = 6000000;
|
||||||
self.engine.contractsManager.gasLimit = 6000000;
|
self.engine.contractsManager.gasLimit = 6000000;
|
||||||
self.engine.deployManager.fatalErrors = true;
|
self.engine.deployManager.fatalErrors = true;
|
||||||
|
self.engine.deployManager.deployOnlyOnConfig = true;
|
||||||
self.engine.deployManager.deployContracts(function(err, _result) {
|
self.engine.deployManager.deployContracts(function(err, _result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
|
@ -8,29 +8,6 @@ contract("AnotherStorage", function() {
|
|||||||
},
|
},
|
||||||
"AnotherStorage": {
|
"AnotherStorage": {
|
||||||
args: ["$SimpleStorage"]
|
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() });
|
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||||
|
@ -2,9 +2,13 @@ contract("Test", function() {
|
|||||||
before(function(done) {
|
before(function(done) {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
var contractsConfig = {
|
var contractsConfig = {
|
||||||
|
"Test2": {
|
||||||
|
},
|
||||||
"Test": {
|
"Test": {
|
||||||
"gas": 2000000
|
"gas": 2000000
|
||||||
},
|
},
|
||||||
|
"ZAMyLib": {
|
||||||
|
},
|
||||||
"ZAMyLib2": {
|
"ZAMyLib2": {
|
||||||
"deploy": true
|
"deploy": true
|
||||||
},
|
},
|
||||||
|
@ -10,6 +10,10 @@ describe("Token", function() {
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
var contractsConfig = {
|
var contractsConfig = {
|
||||||
|
"ZAMyLib": {
|
||||||
|
},
|
||||||
|
"Token": {
|
||||||
|
},
|
||||||
"SimpleStorage": {
|
"SimpleStorage": {
|
||||||
args: [100]
|
args: [100]
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user