chain: add fee overflow test; rename error

This commit is contained in:
Javed Khan 2019-05-07 00:12:40 +05:30
parent 812dc1a6f3
commit 4bc0bb2366
No known key found for this signature in database
GPG Key ID: 7E31745B904584E6
2 changed files with 30 additions and 2 deletions

View File

@ -770,7 +770,7 @@ class Chain extends AsyncEmitter {
if (reward > consensus.MAX_MONEY) {
throw new VerifyError(block,
'invalid',
'bad-cb-amount',
'bad-txns-accumulated-fee-outofrange',
100);
}
}

View File

@ -10,7 +10,7 @@ const Script = require('../lib/script/script');
const Chain = require('../lib/blockchain/chain');
const WorkerPool = require('../lib/workers/workerpool');
const Miner = require('../lib/mining/miner');
const MTX = require('../lib/primitives/mtx');
const {Selector, MTX} = require('../lib/primitives/mtx');
const MemWallet = require('./util/memwallet');
const Network = require('../lib/protocol/network');
const Output = require('../lib/primitives/output');
@ -815,6 +815,34 @@ describe('Chain', function() {
'bad-txns-txouttotal-toolarge');
});
it('should fail to connect total fee toolarge', async () => {
const job = await cpu.createJob();
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;
job.refresh();
assert.strictEqual(await mineBlock(job),
'bad-txns-accumulated-fee-outofrange');
consensus.MAX_MONEY = 21000000 * consensus.COIN;
Selector.MAX_FEE = consensus.COIN / 10;
});
it('should mine 111 multisig blocks', async () => {
const flags = common.flags.DEFAULT_FLAGS & ~common.flags.VERIFY_POW;