Skip to content

Commit

Permalink
[VM] tests: only check last block header on the last block
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Aug 21, 2020
1 parent 6a24519 commit 69926b6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/vm/tests/BlockchainTestsRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ module.exports = async function runBlockchainTest(options, testData, t) {
await cacheDB.close()
}

//console.log(testData)
const numBlocks = testData.blocks.length
let currentBlock = 0
let lastBlock = false
for (const raw of testData.blocks) {
currentBlock++
lastBlock = (currentBlock == numBlocks)
const paramFork = `expectException${options.forkConfigTestSuite}`
// Two naming conventions in ethereum/tests to indicate "exception occurs on all HFs" semantics
// Last checked: ethereumjs-testing v1.3.1 (2020-05-11)
Expand Down Expand Up @@ -115,9 +121,10 @@ module.exports = async function runBlockchainTest(options, testData, t) {
// fix for BlockchainTests/GeneralStateTests/stRandom/*
testData.lastblockhash = testData.lastblockhash.substr(2)
}
if (expectException !== undefined) {
if (expectException !== undefined && lastBlock) { // only check last block hash on last block
t.equal(headBlock.hash().toString('hex'), testData.lastblockhash, 'last block hash')
}

// if the test fails, then block.header is the prej because
// vm.runBlock has a check that prevents the actual postState from being
// imported if it is not equal to the expected postState. it is useful
Expand All @@ -131,7 +138,7 @@ module.exports = async function runBlockchainTest(options, testData, t) {
if (options.debug) {
await verifyPostConditions(state, testData.postState, t)
}
if (expectException !== undefined) {
if (expectException !== undefined && lastBlock) {
t.equal(
blockchain.meta.rawHead.toString('hex'),
testData.lastblockhash,
Expand Down

0 comments on commit 69926b6

Please sign in to comment.