diff --git a/dapps/tests/app/test/another_storage_spec.js b/dapps/tests/app/test/another_storage_spec.js index 290699fee..966b1053e 100644 --- a/dapps/tests/app/test/another_storage_spec.js +++ b/dapps/tests/app/test/another_storage_spec.js @@ -4,13 +4,15 @@ const AnotherStorage = require('Embark/contracts/AnotherStorage'); const SimpleStorage = require('Embark/contracts/SimpleStorage'); let accounts, defaultAccount; +const numAddresses = 10; config({ blockchain: { "accounts": [ { "mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm", - balance: "5ether" + balance: "5ether", + numAddresses: 10 } ] }, @@ -42,6 +44,16 @@ contract("AnotherStorage", function() { assert.ok(parseInt(balance, 10) <= 5000000000000000000); }); + it("should have the right balance for all other accounts ", async function() { + let balance; + + for (let i = 1; i < numAddresses - 3; i++) { + balance = await web3.eth.getBalance(accounts[i]); + console.log('Account', i , balance); + assert.strictEqual(parseInt(balance, 10), 5000000000000000000, `Account ${i} doesn't have the balance set`); + } + }); + it("set SimpleStorage address", async function() { let result = await AnotherStorage.methods.simpleStorageAddress().call(); assert.equal(result.toString(), SimpleStorage.options.address); diff --git a/packages/plugins/accounts-manager/src/index.ts b/packages/plugins/accounts-manager/src/index.ts index 99d3871ff..2f5218105 100644 --- a/packages/plugins/accounts-manager/src/index.ts +++ b/packages/plugins/accounts-manager/src/index.ts @@ -148,12 +148,16 @@ export default class AccountsManager { } try { const coinbase = await web3.eth.getCoinbase(); - const fundingAccounts = this.accounts - .filter((account) => account.address) - .map((account) => { - return fundAccount(web3, account.address, coinbase, account.hexBalance); + const accts = this.accounts + .filter((account) => account.address); + + async.eachLimit(accts, 1, (acct, eachCb) => { + fundAccount(web3, acct.address, coinbase, acct.hexBalance) + .then(() => { + eachCb(); + }) + .catch(eachCb); }); - await Promise.all([fundingAccounts]); } catch (err) { this.logger.error(__("Error funding accounts"), err.message || err); }