aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-11-08 04:00:14 +0800
committerDan Finlay <dan@danfinlay.com>2016-11-08 04:00:14 +0800
commit553a6da0117d94a6a3be3707266bdc09e67f9103 (patch)
treecc3558d3aa1cfbfaf394a8b5e17b153464d944d2 /test
parentfc26a0a8991759a54409096d0c7896da86cea4b7 (diff)
downloadtangerine-wallet-browser-553a6da0117d94a6a3be3707266bdc09e67f9103.tar
tangerine-wallet-browser-553a6da0117d94a6a3be3707266bdc09e67f9103.tar.gz
tangerine-wallet-browser-553a6da0117d94a6a3be3707266bdc09e67f9103.tar.bz2
tangerine-wallet-browser-553a6da0117d94a6a3be3707266bdc09e67f9103.tar.lz
tangerine-wallet-browser-553a6da0117d94a6a3be3707266bdc09e67f9103.tar.xz
tangerine-wallet-browser-553a6da0117d94a6a3be3707266bdc09e67f9103.tar.zst
tangerine-wallet-browser-553a6da0117d94a6a3be3707266bdc09e67f9103.zip
Fix 787 gas buffer bug
Diffstat (limited to 'test')
-rw-r--r--test/unit/keyring-controller-test.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/test/unit/keyring-controller-test.js b/test/unit/keyring-controller-test.js
index 0076d9ebe..15de92c6c 100644
--- a/test/unit/keyring-controller-test.js
+++ b/test/unit/keyring-controller-test.js
@@ -147,9 +147,25 @@ describe('KeyringController', function() {
})
})
+ describe('#addGasBuffer', function() {
+ it('adds 100k gas buffer to estimates', function() {
+
+ const gas = '0x04ee59' // Actual estimated gas example
+ const tooBigOutput = '0x80674f9' // Actual bad output
+ const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
+ const correctBuffer = new BN('100000', 10)
+ const correct = bnGas.add(correctBuffer)
+
+ const tooBig = new BN(tooBigOutput, 16)
+ const result = keyringController.addGasBuffer(gas)
+ const bnResult = new BN(ethUtil.stripHexPrefix(result), 16)
+
+ assert.equal(result.indexOf('0x'), 0, 'included hex prefix')
+ assert(bnResult.gt(bnGas), 'Estimate increased in value.')
+ assert.equal(bnResult.sub(bnGas).toString(10), '100000', 'added 100k gas')
+ assert.equal(result, '0x' + correct.toString(16), 'Added the right amount')
+ assert.notEqual(result, tooBigOutput, 'not that bad estimate')
+ })
+ })
})
-
-
-
-