aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/tx-utils-test.js
blob: 65233e1d92628d7b6014e8d1db6c4f955a99c690 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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() {
    it('multiplies by 1.5', function() {
      const input = '0x123fad'
      const output = txUtils.addGasBuffer(input, '0x3d4c52') //0x3d4c52 is 4mil for dummy gas limit

      const inputBn = new BN(ethUtil.stripHexPrefix(input), 'hex')
      const outputBn = new BN(ethUtil.stripHexPrefix(output), 'hex')
      const expectedBn = inputBn.muln(1.5)
      assert(outputBn.eq(expectedBn), 'returns 1.5 the input value')
    })
  })
})