Merge pull request #493 from embark-framework/bug_fix/accounts-in-test
fix calling back with accounts
This commit is contained in:
commit
2085b0d0c6
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue