diff --git a/lib/contracts/fundAccount.js b/lib/contracts/fundAccount.js index cb9baadea..35470b547 100644 --- a/lib/contracts/fundAccount.js +++ b/lib/contracts/fundAccount.js @@ -1,8 +1,12 @@ const async = require('async'); -const TARGET = 15000000000000000000; +const TARGET = 0x7FFFFFFFFFFFFFFF; const ALREADY_FUNDED = 'alreadyFunded'; -function fundAccount(web3, accountAddress, callback) { +function fundAccount(web3, accountAddress, hexBalance, callback) { + if (!hexBalance) { + hexBalance = TARGET; + } + const targetBalance = (typeof hexBalance === 'string') ? parseInt(hexBalance, 16) : hexBalance; let accountBalance; let coinbaseAddress; let lastNonce; @@ -14,7 +18,7 @@ function fundAccount(web3, accountAddress, callback) { if (err) { return next(err); } - if (balance >= TARGET) { + if (balance >= targetBalance) { return next(ALREADY_FUNDED); } accountBalance = balance; @@ -56,7 +60,7 @@ function fundAccount(web3, accountAddress, callback) { web3.eth.sendTransaction({ from: coinbaseAddress, to: accountAddress, - value: TARGET - accountBalance, + value: targetBalance - accountBalance, gasPrice: gasPrice, nonce: lastNonce }, next); diff --git a/lib/contracts/provider.js b/lib/contracts/provider.js index f93379627..0e60ee86a 100644 --- a/lib/contracts/provider.js +++ b/lib/contracts/provider.js @@ -65,7 +65,7 @@ class Provider { return callback(); } async.each(self.accounts, (account, eachCb) => { - fundAccount(self.web3, account.address, eachCb); + fundAccount(self.web3, account.address, account.hexBalance, eachCb); }, callback); }