From 435e5eba03c97523d44aada5efa6aaf2bd842741 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 6 Jun 2018 13:54:20 -0400 Subject: [PATCH] fix calling back with accounts --- lib/tests/test.js | 12 +++++++----- test_apps/test_app/test/simple_storage_spec.js | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index cbf8af0e1..9cc19a0c2 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -137,10 +137,10 @@ class Test { } self.accounts = accounts; self.web3.eth.defaultAccount = accounts[0]; - next(); + next(null, accounts); }); }, - function createContractObject(next) { + function createContractObject(accounts, next) { async.each(Object.keys(self.engine.contractsManager.contracts), (contractName, eachCb) => { const contract = self.engine.contractsManager.contracts[contractName]; if (!self.contracts[contractName]) { @@ -150,14 +150,16 @@ class Test { {from: self.web3.eth.defaultAccount, gas: 6000000})); self.contracts[contractName].address = contract.deployedAddress; eachCb(); - }, next); + }, (err) => { + next(err, accounts); + }); } - ], function (err) { + ], function (err, accounts) { if (err) { console.log(__('terminating due to error')); return callback(err); } - callback(); + callback(null, accounts); }); } diff --git a/test_apps/test_app/test/simple_storage_spec.js b/test_apps/test_app/test/simple_storage_spec.js index df79d7d0a..7034bb635 100644 --- a/test_apps/test_app/test/simple_storage_spec.js +++ b/test_apps/test_app/test/simple_storage_spec.js @@ -1,15 +1,16 @@ -/*global contract, config, it, embark, assert*/ +/*global contract, config, it, embark, assert, web3*/ const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +let accounts; config({ contracts: { "SimpleStorage": { args: [100], - onDeploy: [ - "SimpleStorage.methods.setRegistar(web3.eth.defaultAccount).send()" - ] + onDeploy: ["SimpleStorage.methods.setRegistar(web3.eth.defaultAccount).send()"] } } +}, (err, theAccounts) => { + accounts = theAccounts; }); contract("SimpleStorage", function () { @@ -29,9 +30,10 @@ contract("SimpleStorage", function () { it("should set defaultAccount", async function () { let result = await SimpleStorage.methods.registar().call(); assert.strictEqual(result, web3.eth.defaultAccount); + assert.strictEqual(accounts[0], web3.eth.defaultAccount); }); - it("should alias contract address", async function () { + it("should alias contract address", function () { assert.strictEqual(SimpleStorage.options.address, SimpleStorage.address); });