aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/tx-utils-test.js
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-08-05 02:40:22 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-08-05 02:40:22 +0800
commit54739cb798b70e14d7774d9e92745188afca5461 (patch)
tree56ede904f92967cc3a88dfbafb497984b89b891b /test/unit/tx-utils-test.js
parent4ac0b972025ddd55a9a42b4a15db0a5f207f4078 (diff)
downloadtangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar.gz
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar.bz2
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar.lz
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar.xz
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar.zst
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.zip
test for pending tx watcher
Diffstat (limited to 'test/unit/tx-utils-test.js')
-rw-r--r--test/unit/tx-utils-test.js58
1 files changed, 5 insertions, 53 deletions
diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js
index a43bcfb35..43128b977 100644
--- a/test/unit/tx-utils-test.js
+++ b/test/unit/tx-utils-test.js
@@ -1,7 +1,7 @@
const assert = require('assert')
-const ethUtil = require('ethereumjs-util')
-const BN = ethUtil.BN
+const BN = require('bn.js')
+const { hexToBn, bnToHex } = require('../../app/scripts/lib/util')
const TxUtils = require('../../app/scripts/lib/tx-utils')
@@ -16,44 +16,6 @@ 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 = {
@@ -96,7 +58,7 @@ describe('txUtils', function () {
assert(outputBn.eq(expectedBn), 'returns the original estimatedGas value')
})
- it('buffers up to reccomend gas limit reccomended ceiling', function () {
+ it('buffers up to recommend gas limit recommended ceiling', function () {
// naive estimatedGas: 0x16e360 (1.5 mil)
const inputHex = '0x16e360'
// dummy gas limit: 0x1e8480 (2 mil)
@@ -107,17 +69,7 @@ describe('txUtils', function () {
// const inputBn = hexToBn(inputHex)
// const outputBn = hexToBn(output)
const expectedHex = bnToHex(ceilGasLimitBn)
- assert.equal(output, expectedHex, 'returns the gas limit reccomended ceiling value')
+ assert.equal(output, expectedHex, 'returns the gas limit recommended ceiling value')
})
})
-})
-
-// util
-
-function hexToBn (inputHex) {
- return new BN(ethUtil.stripHexPrefix(inputHex), 16)
-}
-
-function bnToHex (inputBn) {
- return ethUtil.addHexPrefix(inputBn.toString(16))
-}
+}) \ No newline at end of file