Merge pull request #493 from embark-framework/bug_fix/accounts-in-test

fix calling back with accounts
This commit is contained in:
Iuri Matias 2018-06-06 14:08:18 -04:00 committed by GitHub
commit 2085b0d0c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -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);
});
}

View File

@ -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);
});