From d53fa0a1c53def06d34b55c555903b7c44a6d32f Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Tue, 7 May 2019 03:59:15 +0530 Subject: [PATCH] chain: extend try..finally; restore consts to copy --- test/chain-test.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/chain-test.js b/test/chain-test.js index 747d71d2..325e37ba 100644 --- a/test/chain-test.js +++ b/test/chain-test.js @@ -817,31 +817,33 @@ describe('Chain', function() { it('should fail to connect total fee toolarge', async () => { const job = await cpu.createJob(); + const outputs = [{ address: wallet.getAddress(), value: 0 }]; Selector.MAX_FEE = 50 * consensus.COIN; - - const outputs = [{ address: wallet.getAddress(), value: 0 }]; - const tx1 = await wallet.send({ - outputs: outputs, - hardFee: Selector.MAX_FEE - }); - job.pushTX(tx1.toTX()); - - const tx2 = await wallet.send({ - outputs: outputs, - hardFee: Selector.MAX_FEE - }); - job.pushTX(tx2.toTX()); - - consensus.MAX_MONEY = tx1.getFee() + tx2.getFee() - 1; + const maxFee = Selector.MAX_FEE; + const maxMoney = consensus.MAX_MONEY; try { + const tx1 = await wallet.send({ + outputs: outputs, + hardFee: Selector.MAX_FEE + }); + job.pushTX(tx1.toTX()); + + const tx2 = await wallet.send({ + outputs: outputs, + hardFee: Selector.MAX_FEE + }); + job.pushTX(tx2.toTX()); + + consensus.MAX_MONEY = tx1.getFee() + tx2.getFee() - 1; + job.refresh(); assert.strictEqual(await mineBlock(job), 'bad-txns-accumulated-fee-outofrange'); } finally { - consensus.MAX_MONEY = 21000000 * consensus.COIN; - Selector.MAX_FEE = consensus.COIN / 10; + Selector.MAX_FEE = maxFee; + consensus.MAX_MONEY = maxMoney; } });