Skip to content

Commit 9ec8d61

Browse files
committed
update deploy spec
1 parent 1167c9c commit 9ec8d61

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

test/deploy.js

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ setDeployConfig = function(config) {
2222
return new Deploy('development', config.files, blockchainConfig, contractsConfig, chainManager, true, false, web3);
2323
}
2424

25+
function Done(fn) {
26+
var self = this;
27+
var called = false;
28+
29+
/**
30+
*
31+
* @param {*} params...
32+
*/
33+
this.trigger = function (params) {
34+
if(called) {
35+
return;
36+
}
37+
38+
fn.apply(self, arguments);
39+
called = true;
40+
};
41+
}
42+
2543
describe('embark.deploy', function() {
2644

2745
describe('contracts as arguments to other contracts', function() {
@@ -39,7 +57,8 @@ describe('embark.deploy', function() {
3957
contracts: 'test/support/arguments.yml'
4058
});
4159

42-
it("should deploy contracts", function(done) {
60+
it("should deploy contracts", function(fn) {
61+
var doneWrap = new Done(fn);
4362

4463
deploy.deploy_contracts("development", function() {
4564
var all_contracts = ['Wallet', 'SimpleStorage', 'AnotherStorage', 'Wallets'];
@@ -49,7 +68,7 @@ describe('embark.deploy', function() {
4968
assert.equal(deploy.deployedContracts.hasOwnProperty(className), true);
5069
}
5170

52-
done();
71+
doneWrap.trigger();
5372
});
5473

5574
});
@@ -95,7 +114,9 @@ describe('embark.deploy', function() {
95114
contracts: 'test/support/arguments2.yml'
96115
});
97116

98-
it("should deploy contracts", function(done) {
117+
it("should deploy contracts", function(fn) {
118+
var doneWrap = new Done(fn);
119+
99120
deploy.deploy_contracts("development", function() {
100121

101122
var all_contracts = ['token', 'Crowdsale'];
@@ -105,7 +126,7 @@ describe('embark.deploy', function() {
105126
assert.equal(deploy.deployedContracts.hasOwnProperty(className), true);
106127
}
107128

108-
done();
129+
doneWrap.trigger();
109130
});
110131

111132
});
@@ -126,7 +147,9 @@ describe('embark.deploy', function() {
126147
contracts: 'test/support/instances.yml'
127148
});
128149

129-
it("should deploy contracts", function(done) {
150+
it("should deploy contracts", function(fn) {
151+
var doneWrap = new Done(fn);
152+
130153
deploy.deploy_contracts("development", function() {
131154

132155
var all_contracts = ['BarStorage', 'FooStorage'];
@@ -137,7 +160,7 @@ describe('embark.deploy', function() {
137160
}
138161
assert.notEqual(deploy.deployedContracts.hasOwnProperty('SimpleStorage'), true);
139162

140-
done();
163+
doneWrap.trigger();
141164
});
142165
});
143166

@@ -158,7 +181,9 @@ describe('embark.deploy', function() {
158181
contracts: 'test/support/arguments3.yml'
159182
});
160183

161-
it("should deploy contracts", function(done) {
184+
it("should deploy contracts", function(fn) {
185+
var doneWrap = new Done(fn);
186+
162187
deploy.deploy_contracts("development", function() {
163188
var all_contracts = ['DataSource', 'MyDataSource', 'Manager'];
164189
for(var i=0; i < all_contracts.length; i++) {
@@ -167,11 +192,13 @@ describe('embark.deploy', function() {
167192
assert.equal(deploy.deployedContracts.hasOwnProperty(className), true);
168193
}
169194

170-
done();
195+
doneWrap.trigger();
171196
});
172197
});
173198

174-
it("should execute deploy changes", function() {
199+
it("should execute deploy changes", function(fn) {
200+
var doneWrap = new Done(fn);
201+
175202
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));
176203
web3.eth.defaultAccount = web3.eth.accounts[0];
177204

@@ -188,6 +215,8 @@ describe('embark.deploy', function() {
188215

189216
assert.equal(DataSource.storeData().toNumber(), 5);
190217
assert.equal(Manager.data().toString(), my_data_source_address);
218+
219+
doneWrap.trigger();
191220
});
192221

193222
});
@@ -206,7 +235,9 @@ describe('embark.deploy', function() {
206235
contracts: 'test/support/address.yml'
207236
});
208237

209-
it("should not deploy contracts with addresses defined", function(done) {
238+
it("should not deploy contracts with addresses defined", function(fn) {
239+
var doneWrap = new Done(fn);
240+
210241
deploy.deploy_contracts("development", function() {
211242
var expected_deploys = ['SimpleStorage', 'BarStorage', 'FooStorage'];
212243

@@ -218,6 +249,8 @@ describe('embark.deploy', function() {
218249

219250
assert.equal(deploy.deployedContracts['SimpleStorage'], '0x123');
220251
assert.equal(deploy.deployedContracts['BarStorage'], '0x234');
252+
253+
doneWrap.trigger();
221254
});
222255
});
223256

0 commit comments

Comments
 (0)