chain: extend try..finally; restore consts to copy

This commit is contained in:
Javed Khan 2019-05-07 03:59:15 +05:30
parent 49143b2c16
commit d53fa0a1c5
No known key found for this signature in database
GPG Key ID: 7E31745B904584E6

View File

@ -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;
}
});