2017-08-04 20:36:27 +02:00
|
|
|
const assert = require('assert')
|
2018-05-21 14:59:26 +02:00
|
|
|
const { sufficientBalance } = require('../../../app/scripts/lib/util')
|
2017-08-04 20:36:27 +02:00
|
|
|
|
|
|
|
|
2017-08-04 20:40:22 +02:00
|
|
|
describe('SufficientBalance', function () {
|
2017-08-04 20:36:27 +02:00
|
|
|
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 = 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 = 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 = sufficientBalance(tx, balance)
|
|
|
|
assert.ok(!result, 'insufficient balance found.')
|
|
|
|
})
|
|
|
|
})
|