chain: add fee overflow test; rename error
This commit is contained in:
parent
812dc1a6f3
commit
4bc0bb2366
@ -770,7 +770,7 @@ class Chain extends AsyncEmitter {
|
|||||||
if (reward > consensus.MAX_MONEY) {
|
if (reward > consensus.MAX_MONEY) {
|
||||||
throw new VerifyError(block,
|
throw new VerifyError(block,
|
||||||
'invalid',
|
'invalid',
|
||||||
'bad-cb-amount',
|
'bad-txns-accumulated-fee-outofrange',
|
||||||
100);
|
100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ const Script = require('../lib/script/script');
|
|||||||
const Chain = require('../lib/blockchain/chain');
|
const Chain = require('../lib/blockchain/chain');
|
||||||
const WorkerPool = require('../lib/workers/workerpool');
|
const WorkerPool = require('../lib/workers/workerpool');
|
||||||
const Miner = require('../lib/mining/miner');
|
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 MemWallet = require('./util/memwallet');
|
||||||
const Network = require('../lib/protocol/network');
|
const Network = require('../lib/protocol/network');
|
||||||
const Output = require('../lib/primitives/output');
|
const Output = require('../lib/primitives/output');
|
||||||
@ -815,6 +815,34 @@ describe('Chain', function() {
|
|||||||
'bad-txns-txouttotal-toolarge');
|
'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 () => {
|
it('should mine 111 multisig blocks', async () => {
|
||||||
const flags = common.flags.DEFAULT_FLAGS & ~common.flags.VERIFY_POW;
|
const flags = common.flags.DEFAULT_FLAGS & ~common.flags.VERIFY_POW;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user