From 6f39924e60545ca8ac19995a799c16d0dea11b04 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 8 Nov 2016 08:32:34 -0800 Subject: Increase gas buffer Fixes #795 --- test/unit/idStore-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/unit') diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js index 46b3d4809..b0940d2fa 100644 --- a/test/unit/idStore-test.js +++ b/test/unit/idStore-test.js @@ -168,9 +168,8 @@ describe('IdentityStore', function() { }) 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 correctBuffer = new BN('200000', 10) const correct = bnGas.add(correctBuffer) const tooBig = new BN(tooBigOutput, 16) -- cgit v1.2.3 From 7068d2e71c6d1ddb68095916dc16f3ff1f283590 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 8 Nov 2016 08:39:41 -0800 Subject: Adjust gas buffer to be 20% over estimate --- test/unit/idStore-test.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'test/unit') diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js index b0940d2fa..064483ba0 100644 --- a/test/unit/idStore-test.js +++ b/test/unit/idStore-test.js @@ -159,7 +159,7 @@ describe('IdentityStore', function() { assert.equal(result.indexOf('0x'), 0, 'include hex prefix') }) - it('buffers reasonably', function() { + it('buffers 20%', function() { const idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { @@ -169,18 +169,17 @@ describe('IdentityStore', function() { const gas = '0x04ee59' // Actual estimated gas example const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16) - const correctBuffer = new BN('200000', 10) + const five = new BN('5', 10) + const correctBuffer = bnGas.div(five) 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(bnResult.sub(bnGas).toString(10), correctBuffer.toString(10), 'added 20% gas') assert.equal(result, '0x' + correct.toString(16), 'Added the right amount') - assert.notEqual(result, tooBigOutput, 'not that bad estimate') }) }) -- cgit v1.2.3