diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-09-08 03:30:25 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-09-08 03:30:25 +0800 |
commit | 40585744365c128d1f64c5bf93ee8cedc9e91dae (patch) | |
tree | 8726029de67dc2106d8a90700adf248efb06d893 /test/unit | |
parent | b6e8791bc2bc912d874edcc92fcf3c4ce5a9b72a (diff) | |
download | tangerine-wallet-browser-40585744365c128d1f64c5bf93ee8cedc9e91dae.tar tangerine-wallet-browser-40585744365c128d1f64c5bf93ee8cedc9e91dae.tar.gz tangerine-wallet-browser-40585744365c128d1f64c5bf93ee8cedc9e91dae.tar.bz2 tangerine-wallet-browser-40585744365c128d1f64c5bf93ee8cedc9e91dae.tar.lz tangerine-wallet-browser-40585744365c128d1f64c5bf93ee8cedc9e91dae.tar.xz tangerine-wallet-browser-40585744365c128d1f64c5bf93ee8cedc9e91dae.tar.zst tangerine-wallet-browser-40585744365c128d1f64c5bf93ee8cedc9e91dae.zip |
Add basic test for valueFor
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/pending-balance-test.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/test/unit/pending-balance-test.js b/test/unit/pending-balance-test.js index 9077e8f14..7f20270cb 100644 --- a/test/unit/pending-balance-test.js +++ b/test/unit/pending-balance-test.js @@ -4,11 +4,31 @@ const MockTxGen = require('../lib/mock-tx-gen') const BN = require('ethereumjs-util').BN let providerResultStub = {} +const etherBn = new BN(String(1e18)) +const ether = '0x' + etherBn.toString(16) + describe('PendingBalanceCalculator', function () { let balanceCalculator + describe('#valueFor(tx)', function () { + it('returns a BN for a given tx value', function () { + const txGen = new MockTxGen() + pendingTxs = txGen.generate({ + status: 'submitted', + txParams: { + value: ether, + gasPrice: '0x0', + gas: '0x0', + } + }, { count: 1 }) + + const balanceCalculator = generateBalaneCalcWith([], '0x0') + const result = balanceCalculator.valueFor(pendingTxs[0]) + assert.equal(result.toString(), etherBn.toString(), 'computes one ether') + }) + }) + describe('if you have no pending txs and one ether', function () { - const ether = '0x' + (new BN(String(1e18))).toString(16) beforeEach(function () { balanceCalculator = generateBalaneCalcWith([], ether) @@ -21,8 +41,6 @@ describe('PendingBalanceCalculator', function () { }) describe('if you have a one ether pending tx and one ether', function () { - const ether = '0x' + (new BN(String(1e18))).toString(16) - beforeEach(function () { const txGen = new MockTxGen() pendingTxs = txGen.generate({ @@ -40,6 +58,7 @@ describe('PendingBalanceCalculator', function () { it('returns the network balance', async function () { console.log('one') console.dir(balanceCalculator) + console.dir(balanceCalculator.getBalance.toString()) const result = await balanceCalculator.getBalance() console.log('two') console.dir(result) |