Skip to content

Commit

Permalink
Merge pull request #380 from ethereumjs/fix-test-GasLimitHigherThan2p…
Browse files Browse the repository at this point in the history
…63m1

Fix failing blockchain test GasLimitHigherThan2p63m1
  • Loading branch information
holgerd77 committed Nov 6, 2018
2 parents 41e3f63 + 8694c3b commit 383bd5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/runBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = function (opts, cb) {
// run everything
async.series([
beforeBlock,
validateBlock,
processTransactions,
payOmmersAndMiner
], parseBlockResults)
Expand All @@ -81,6 +82,14 @@ module.exports = function (opts, cb) {
self.emit('afterBlock', result, cb)
}

function validateBlock (cb) {
if (new BN(block.header.gasLimit).gte(new BN('8000000000000000', 16))) {
cb(new Error('Invalid block with gas limit greater than (2^63 - 1)'))
} else {
cb()
}
}

/**
* Processes all of the transaction in the block
* @method processTransaction
Expand Down
17 changes: 17 additions & 0 deletions tests/api/runBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ tape('runBlock', async (t) => {
})
})

tape('should fail when block gas limit higher than 2^63-1', async (t) => {
const suite = setup()

const genesis = createGenesis()
const block = new Block({
header: {
...suite.data.blocks[0].header,
gasLimit: Buffer.from('8000000000000000', 16)
}
})
suite.p.runBlock({ block, root: genesis.header.stateRoot })
.then(() => t.fail('should have returned error'))
.catch((e) => t.ok(e.message.includes('Invalid block')))

t.end()
})

tape('should fail when tx gas limit higher than block gas limit', async (t) => {
const suite = setup()

Expand Down

0 comments on commit 383bd5d

Please sign in to comment.