Merge branch 'master' into i328-MultiVault

feature/default_network_editable
Dan Finlay 8 years ago
commit 161ff62fdc
  1. 3
      CHANGELOG.md
  2. 10
      app/scripts/lib/idStore.js
  3. 28
      test/unit/idStore-test.js
  4. 2
      ui/app/info.js

@ -2,6 +2,9 @@
## Current Master ## Current Master
- Fix gas estimation bug.
- Fix github link on info page to point at current repository.
## 2.13.6 2016-10-26 ## 2.13.6 2016-10-26
- Add a check for improper Transaction data. - Add a check for improper Transaction data.

@ -285,11 +285,11 @@ IdentityStore.prototype.checkForDelegateCall = function (codeHex) {
} }
} }
IdentityStore.prototype.addGasBuffer = function (gasHex) { const gasBuffer = new BN('100000', 10)
var gas = new BN(gasHex, 16) IdentityStore.prototype.addGasBuffer = function (gas) {
var buffer = new BN('100000', 10) const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
var result = gas.add(buffer) const correct = bnGas.add(gasBuffer)
return ethUtil.addHexPrefix(result.toString(16)) return ethUtil.addHexPrefix(correct.toString(16))
} }
// comes from metamask ui // comes from metamask ui

@ -142,6 +142,7 @@ describe('IdentityStore', function() {
}) })
describe('#addGasBuffer', function() { describe('#addGasBuffer', function() {
it('formats the result correctly', function() {
const idStore = new IdentityStore({ const idStore = new IdentityStore({
configManager: configManagerGen(), configManager: configManagerGen(),
ethStore: { ethStore: {
@ -158,6 +159,32 @@ describe('IdentityStore', function() {
assert.equal(result.indexOf('0x'), 0, 'include hex prefix') 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(ethUtil.stripHexPrefix(gas), 16)
const correctBuffer = new BN('100000', 10)
const correct = bnGas.add(correctBuffer)
const tooBig = new BN(tooBigOutput, 16)
const result = idStore.addGasBuffer(gas)
const bnResult = new BN(ethUtil.stripHexPrefix(result), 16)
assert.equal(result.indexOf('0x'), 0, 'included hex prefix')
assert(bnResult.gt(bnGas), 'Estimate increased in value.')
assert.equal(bnResult.sub(bnGas).toString(10), '100000', 'added 100k gas')
assert.equal(result, '0x' + correct.toString(16), 'Added the right amount')
assert.notEqual(result, tooBigOutput, 'not that bad estimate')
})
})
describe('#checkForDelegateCall', function() { describe('#checkForDelegateCall', function() {
const idStore = new IdentityStore({ const idStore = new IdentityStore({
configManager: configManagerGen(), configManager: configManagerGen(),
@ -169,4 +196,5 @@ describe('IdentityStore', function() {
var result = idStore.checkForDelegateCall(delegateCallCode) var result = idStore.checkForDelegateCall(delegateCallCode)
assert.equal(result, true, 'no delegate call in provided code') assert.equal(result, true, 'no delegate call in provided code')
}) })
}) })

@ -145,7 +145,7 @@ InfoScreen.prototype.render = function () {
h('div.fa.fa-github', [ h('div.fa.fa-github', [
h('a.info', { h('a.info', {
href: 'https://github.com/metamask/talk/issues', href: 'https://github.com/MetaMask/metamask-plugin/issues',
target: '_blank', target: '_blank',
onClick (event) { this.navigateTo(event.target.href) }, onClick (event) { this.navigateTo(event.target.href) },
}, 'Start a thread on GitHub'), }, 'Start a thread on GitHub'),

Loading…
Cancel
Save