mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
change BN.mul to BN.muln
This commit is contained in:
parent
de44cd9ba4
commit
4916331c53
@ -71,7 +71,7 @@ module.exports = class txProviderUtils {
|
|||||||
addGasBuffer (gas, blockGasLimitHex) {
|
addGasBuffer (gas, blockGasLimitHex) {
|
||||||
const blockGasLimitBn = new BN(ethUtil.stripHexPrefix(blockGasLimitHex), 16)
|
const blockGasLimitBn = new BN(ethUtil.stripHexPrefix(blockGasLimitHex), 16)
|
||||||
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
|
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
|
||||||
const bufferedGas = bnGas.mul(1.5)
|
const bufferedGas = bnGas.muln(1.5)
|
||||||
|
|
||||||
if (bnGas.gt(blockGasLimitBn)) return gas
|
if (bnGas.gt(blockGasLimitBn)) return gas
|
||||||
if (bufferedGas.lt(blockGasLimitBn)) return ethUtil.addHexPrefix(bufferedGas.toString(16))
|
if (bufferedGas.lt(blockGasLimitBn)) return ethUtil.addHexPrefix(bufferedGas.toString(16))
|
||||||
|
@ -13,16 +13,14 @@ describe('txUtils', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('addGasBuffer', function() {
|
describe('addGasBuffer', function() {
|
||||||
describe('multiplies by 1.5', function() {
|
it('multiplies by 1.5', function() {
|
||||||
it('over a value', function() {
|
const input = '0x123fad'
|
||||||
const input = '0x123fad'
|
const output = txUtils.addGasBuffer(input, '0x3d4c52') //0x3d4c52 is 4mil for dummy gas limit
|
||||||
const output = txUtils.addGasBuffer(input, '0x3d4c52') //0x3d4c52 is 4mil for dummy gas limit
|
|
||||||
|
|
||||||
const inputBn = new BN(input, 'hex')
|
const inputBn = new BN(ethUtil.stripHexPrefix(input), 'hex')
|
||||||
const outputBn = new BN(output, 'hex')
|
const outputBn = new BN(ethUtil.stripHexPrefix(output), 'hex')
|
||||||
const expectedBn = inputBn.mul(1.5)
|
const expectedBn = inputBn.muln(1.5)
|
||||||
assert(outputBn.eq(expectedBn), 'returns 1.5 the input value')
|
assert(outputBn.eq(expectedBn), 'returns 1.5 the input value')
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user