aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/tx-utils-test.js
blob: 44d8e13e9e7a15e13f5b368456b7fc37423aa09f (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
27
28
29
30
31
32
33
34
35
36
37
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')
      })
    })
  })
})