aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-03-08 14:51:39 +0800
committerkumavis <aaron@kumavis.me>2017-03-08 14:51:39 +0800
commit92b8443824bffca219b146028d5685e6aa1ffabf (patch)
treeb553981990eefc8eb9eaf5028b0e022d324f9c3e /test
parentc063fab9932c6b90414fd7db7849012d6594afb7 (diff)
downloadtangerine-wallet-browser-92b8443824bffca219b146028d5685e6aa1ffabf.tar
tangerine-wallet-browser-92b8443824bffca219b146028d5685e6aa1ffabf.tar.gz
tangerine-wallet-browser-92b8443824bffca219b146028d5685e6aa1ffabf.tar.bz2
tangerine-wallet-browser-92b8443824bffca219b146028d5685e6aa1ffabf.tar.lz
tangerine-wallet-browser-92b8443824bffca219b146028d5685e6aa1ffabf.tar.xz
tangerine-wallet-browser-92b8443824bffca219b146028d5685e6aa1ffabf.tar.zst
tangerine-wallet-browser-92b8443824bffca219b146028d5685e6aa1ffabf.zip
tx-utils - add encoding utils
Diffstat (limited to 'test')
-rw-r--r--test/unit/tx-utils-test.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js
index 641b4942f..e57b25e83 100644
--- a/test/unit/tx-utils-test.js
+++ b/test/unit/tx-utils-test.js
@@ -19,8 +19,8 @@ describe('txUtils', function() {
// dummy gas limit: 0x3d4c52 (4 mil)
const blockGasLimitHex = '0x3d4c52'
const output = txUtils.addGasBuffer(inputHex, blockGasLimitHex)
- const inputBn = new BN(ethUtil.stripHexPrefix(inputHex), 'hex')
- const outputBn = new BN(ethUtil.stripHexPrefix(output), 'hex')
+ const inputBn = hexToBn(inputHex)
+ const outputBn = hexToBn(output)
const expectedBn = inputBn.muln(1.5)
assert(outputBn.eq(expectedBn), 'returns 1.5 the input value')
})
@@ -31,9 +31,9 @@ describe('txUtils', function() {
// dummy gas limit: 0x0f4240 (1 mil)
const blockGasLimitHex = '0x0f4240'
const output = txUtils.addGasBuffer(inputHex, blockGasLimitHex)
- const inputBn = new BN(ethUtil.stripHexPrefix(inputHex), 'hex')
- const outputBn = new BN(ethUtil.stripHexPrefix(output), 'hex')
- const expectedBn = new BN(ethUtil.stripHexPrefix(inputHex), 'hex')
+ const inputBn = hexToBn(inputHex)
+ const outputBn = hexToBn(output)
+ const expectedBn = hexToBn(inputHex)
assert(outputBn.eq(expectedBn), 'returns the original estimatedGas value')
})
@@ -43,10 +43,16 @@ describe('txUtils', function() {
// dummy gas limit: 0x1e8480 (2 mil)
const blockGasLimitHex = '0x1e8480'
const output = txUtils.addGasBuffer(inputHex, blockGasLimitHex)
- const inputBn = new BN(ethUtil.stripHexPrefix(inputHex), 'hex')
- const outputBn = new BN(ethUtil.stripHexPrefix(output), 'hex')
- const expectedBn = new BN(ethUtil.stripHexPrefix(blockGasLimitHex), 'hex')
+ const inputBn = hexToBn(inputHex)
+ const outputBn = hexToBn(output)
+ const expectedBn = hexToBn(blockGasLimitHex)
assert(outputBn.eq(expectedBn), 'returns the block gas limit value')
})
})
})
+
+// util
+
+function hexToBn(inputHex) {
+ return new BN(ethUtil.stripHexPrefix(inputHex), 16)
+} \ No newline at end of file