support deploy commands specifying contract

This commit is contained in:
Iuri Matias 2015-08-02 20:50:12 -04:00
parent 3757e41ea0
commit c0420d74a8
4 changed files with 22 additions and 4 deletions

View File

@ -117,8 +117,12 @@ Deploy.prototype.execute_cmds = function(cmds) {
for (var i = 0; i < cmds.length; i++) {
var cmd = cmds[i];
// need to initialize all variables of deployed contracts making them
// available to deployment
for(className in this.deployedContracts) {
var contractAddress = this.deployedContracts[className];
var re = new RegExp("\\$" + className, 'g');
cmd = cmd.replace(re, '"' + contractAddress + '"');
}
console.log("executing: " + cmd);
eval(cmd);

View File

@ -135,7 +135,7 @@ describe('embark.deploy', function() {
deploy.deploy_contracts("development");
it("should deploy contracts", function() {
var all_contracts = ['DataSource', 'Manager'];
var all_contracts = ['DataSource', 'MyDataSource', 'Manager'];
for(var i=0; i < all_contracts.length; i++) {
var className = all_contracts[i];
@ -149,10 +149,17 @@ describe('embark.deploy', function() {
data_source_abi = deploy.contractDB['DataSource'].compiled.info.abiDefinition;
data_source_address = deploy.deployedContracts['DataSource'];
my_data_source_abi = deploy.contractDB['MyDataSource'].compiled.info.abiDefinition;
my_data_source_address = deploy.deployedContracts['MyDataSource'];
manager_abi = deploy.contractDB['Manager'].compiled.info.abiDefinition;
manager_address = deploy.deployedContracts['Manager'];
DataSource = web3.eth.contract(data_source_abi).at(data_source_address);
MyDataSource = web3.eth.contract(my_data_source_abi).at(my_data_source_address);
ManagerSource = web3.eth.contract(manager_abi).at(manager_address);
assert.equal(DataSource.storeData().toNumber(), 5);
assert.equal(Manager.data().toString(), my_data_source_address);
});
});

View File

@ -1,6 +1,9 @@
development:
DataSource:
args:
MyDataSource:
args:
instanceOf: DataSource
Manager:
stubs:
- DataSource
@ -8,4 +11,5 @@ development:
- $DataSource
onDeploy:
- DataSource.set(5)
- Manager.update($MyDataSource)
staging:

View File

@ -1,8 +1,11 @@
contract Manager {
address data;
address public data;
function Manager(address dataAddress) {
data = dataAddress;
}
function update(address _addr) {
data = _addr;
}
}