diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-03-08 03:34:11 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-03-08 03:34:11 +0800 |
commit | e78e642eef21c0219eb025f859edea5817363b3f (patch) | |
tree | 4b677d37f5004d772f1e490d78bd4fdcb98de0d0 /test | |
parent | 2acf991b67bc42fb904ff77af6ff6a7ca3a683fd (diff) | |
download | tangerine-wallet-browser-e78e642eef21c0219eb025f859edea5817363b3f.tar tangerine-wallet-browser-e78e642eef21c0219eb025f859edea5817363b3f.tar.gz tangerine-wallet-browser-e78e642eef21c0219eb025f859edea5817363b3f.tar.bz2 tangerine-wallet-browser-e78e642eef21c0219eb025f859edea5817363b3f.tar.lz tangerine-wallet-browser-e78e642eef21c0219eb025f859edea5817363b3f.tar.xz tangerine-wallet-browser-e78e642eef21c0219eb025f859edea5817363b3f.tar.zst tangerine-wallet-browser-e78e642eef21c0219eb025f859edea5817363b3f.zip |
Add gas buffer test
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/tx-utils-test.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js new file mode 100644 index 000000000..6131ed73f --- /dev/null +++ b/test/unit/tx-utils-test.js @@ -0,0 +1,38 @@ +const assert = require('assert') +const ethUtil = require('ethereumjs-util') +const BN = ethUtil.BN + +const TxUtils = require('../../app/scripts/lib/tx-utils') + + +describe('txUtils', function() { + let txUtils + + before(function() { + txUtils = new TxUtils() + }) + + describe('addGasBuffer', function() { + describe('adds a flat value', function() { + it('over an empty value', function() { + const input = '0x0' + const output = txUtils.addGasBuffer(input) + assert.notEqual(output, input, 'changed the value') + + const inputBn = new BN(input, 'hex') + const outputBn = new BN(output, 'hex') + assert(outputBn.gt(inputBn), 'returns a greater value') + }) + + it('over an value', function() { + const input = '0x123fad' + const output = txUtils.addGasBuffer(input) + assert.notEqual(output, input, 'changed the value') + + const inputBn = new BN(input, 'hex') + const outputBn = new BN(output, 'hex') + assert(outputBn.gt(inputBn), 'returns a greater value') + }) + }) + }) +})
\ No newline at end of file |