mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-09 21:35:58 +00:00
fix(@embark/accounts-manager): limit funding accounts to 1 at a time
This commit is contained in:
parent
776db1b7f7
commit
95b5ae48c6
@ -4,13 +4,15 @@ const AnotherStorage = require('Embark/contracts/AnotherStorage');
|
|||||||
const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
||||||
|
|
||||||
let accounts, defaultAccount;
|
let accounts, defaultAccount;
|
||||||
|
const numAddresses = 10;
|
||||||
|
|
||||||
config({
|
config({
|
||||||
blockchain: {
|
blockchain: {
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm",
|
"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);
|
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() {
|
it("set SimpleStorage address", async function() {
|
||||||
let result = await AnotherStorage.methods.simpleStorageAddress().call();
|
let result = await AnotherStorage.methods.simpleStorageAddress().call();
|
||||||
assert.equal(result.toString(), SimpleStorage.options.address);
|
assert.equal(result.toString(), SimpleStorage.options.address);
|
||||||
|
@ -148,12 +148,16 @@ export default class AccountsManager {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const coinbase = await web3.eth.getCoinbase();
|
const coinbase = await web3.eth.getCoinbase();
|
||||||
const fundingAccounts = this.accounts
|
const accts = this.accounts
|
||||||
.filter((account) => account.address)
|
.filter((account) => account.address);
|
||||||
.map((account) => {
|
|
||||||
return fundAccount(web3, account.address, coinbase, account.hexBalance);
|
async.eachLimit(accts, 1, (acct, eachCb) => {
|
||||||
|
fundAccount(web3, acct.address, coinbase, acct.hexBalance)
|
||||||
|
.then(() => {
|
||||||
|
eachCb();
|
||||||
|
})
|
||||||
|
.catch(eachCb);
|
||||||
});
|
});
|
||||||
await Promise.all([fundingAccounts]);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error(__("Error funding accounts"), err.message || err);
|
this.logger.error(__("Error funding accounts"), err.message || err);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user