aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-07-12 03:18:07 +0800
committerDan Finlay <dan@danfinlay.com>2017-07-12 03:19:01 +0800
commitc7b9e3fb1878cebbab26d5343cc18084a601c6bb (patch)
tree1afe10a7c6f4107486ea32ee72323c75dec707a2 /test/unit
parentd97c6533b87b0a9dd6937c1ca57ec05129ac619b (diff)
downloadtangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar
tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.gz
tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.bz2
tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.lz
tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.xz
tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.zst
tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.zip
Improve insufficient balance checking in retry loop
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/tx-utils-test.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js
index 7ace1f587..a43bcfb35 100644
--- a/test/unit/tx-utils-test.js
+++ b/test/unit/tx-utils-test.js
@@ -16,6 +16,44 @@ describe('txUtils', function () {
}))
})
+ describe('#sufficientBalance', function () {
+ it('returns true if max tx cost is equal to balance.', function () {
+ const tx = {
+ 'value': '0x1',
+ 'gas': '0x2',
+ 'gasPrice': '0x3',
+ }
+ const balance = '0x8'
+
+ const result = txUtils.sufficientBalance(tx, balance)
+ assert.ok(result, 'sufficient balance found.')
+ })
+
+ it('returns true if max tx cost is less than balance.', function () {
+ const tx = {
+ 'value': '0x1',
+ 'gas': '0x2',
+ 'gasPrice': '0x3',
+ }
+ const balance = '0x9'
+
+ const result = txUtils.sufficientBalance(tx, balance)
+ assert.ok(result, 'sufficient balance found.')
+ })
+
+ it('returns false if max tx cost is more than balance.', function () {
+ const tx = {
+ 'value': '0x1',
+ 'gas': '0x2',
+ 'gasPrice': '0x3',
+ }
+ const balance = '0x6'
+
+ const result = txUtils.sufficientBalance(tx, balance)
+ assert.ok(!result, 'insufficient balance found.')
+ })
+ })
+
describe('chain Id', function () {
it('prepares a transaction with the provided chainId', function () {
const txParams = {