mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Added failing test for #787
This commit is contained in:
parent
30ff9b5e10
commit
fff5a6765e
@ -142,6 +142,7 @@ describe('IdentityStore', function() {
|
||||
})
|
||||
|
||||
describe('#addGasBuffer', function() {
|
||||
it('formats the result correctly', function() {
|
||||
const idStore = new IdentityStore({
|
||||
configManager: configManagerGen(),
|
||||
ethStore: {
|
||||
@ -158,6 +159,34 @@ describe('IdentityStore', function() {
|
||||
assert.equal(result.indexOf('0x'), 0, 'include hex prefix')
|
||||
})
|
||||
|
||||
it('buffers reasonably', function() {
|
||||
const idStore = new IdentityStore({
|
||||
configManager: configManagerGen(),
|
||||
ethStore: {
|
||||
addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) },
|
||||
},
|
||||
})
|
||||
|
||||
const gas = '0x04ee59' // Actual estimated gas example
|
||||
const tooBigOutput = '0x80674f9' // Actual bad output
|
||||
const bnGas = new BN(gas, 16)
|
||||
const correctBuffer = new BN('100000', 10)
|
||||
const correct = bnGas.add(correctBuffer)
|
||||
|
||||
const tooBig = new BN(tooBigOutput, 16)
|
||||
console.log(`Pure estimate is ${bnGas.toString(10)}`)
|
||||
console.log(`Too big is ${tooBig.toString(10)}`)
|
||||
console.log(`Buffer should be ${correctBuffer.toString(10)}`)
|
||||
console.log(`correct should be ${correct.toString(10)}`)
|
||||
const result = idStore.addGasBuffer(gas)
|
||||
const bnResult = new BN(result, 16)
|
||||
|
||||
console.log(`Result was ${bnResult.toString(10)}`)
|
||||
assert.equal(result, correct.toString(16), 'add the right amount')
|
||||
assert.notEqual(result, tooBigOutput, 'not that bad estimate')
|
||||
})
|
||||
})
|
||||
|
||||
describe('#checkForDelegateCall', function() {
|
||||
const idStore = new IdentityStore({
|
||||
configManager: configManagerGen(),
|
||||
@ -169,4 +198,5 @@ describe('IdentityStore', function() {
|
||||
var result = idStore.checkForDelegateCall(delegateCallCode)
|
||||
assert.equal(result, true, 'no delegate call in provided code')
|
||||
})
|
||||
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user