Skip to content

Commit 6cb8900

Browse files
committed
update BlockchainTestsRunner for homestead
1 parent 96450d9 commit 6cb8900

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"babel-preset-es2015": "^6.24.0",
1919
"babelify": "^7.3.0",
2020
"ethereumjs-blockchain": "^1.4.1",
21-
"ethereumjs-testing": "^1.0.4",
21+
"ethereumjs-testing": "ethereumjs/ethereumjs-testing#homestead-testing-update",
2222
"ethereumjs-tx": "1.1.0",
2323
"level": "^1.4.0",
2424
"leveldown": "^1.4.6",

tests/BlockchainTestsRunner.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
1818
blockchain.ethash.cacheDB = cacheDB
1919
var vm = new VM({
2020
state: state,
21-
blockchain: blockchain
21+
blockchain: blockchain,
22+
enableHomestead: true
2223
})
2324
var genesisBlock = new Block()
2425

26+
testData.homestead = true
2527
if (testData.homestead) {
2628
vm.on('beforeTx', function (tx) {
2729
tx._homestead = true
@@ -83,8 +85,15 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
8385
function getHead (done) {
8486
vm.blockchain.getHead(function (err, block) {
8587
t.equal(block.hash().toString('hex'), testData.lastblockhash, 'last block hash')
86-
// make sure the state is set beofore checking post conditions
87-
state.root = block.header.stateRoot
88+
// if the test fails, then block.header is the preState because
89+
// vm.runBlock has a check that prevents the actual postState from being
90+
// imported if it is not equal to the expected postState. it is useful
91+
// for debugging to skip this, so that verifyPostConditions will compare
92+
// testData.postState to the actual postState, rather than to the preState.
93+
if (!options.debugging) {
94+
// make sure the state is set before checking post conditions
95+
state.root = block.header.stateRoot
96+
}
8897
done(err)
8998
})
9099
},

tests/tester.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const argv = require('minimist')(process.argv.slice(2))
22
const async = require('async')
33
const tape = require('tape')
44
const testing = require('ethereumjs-testing')
5+
const FORK_CONFIG = 'Homestead'
56
const skip = [
67
'CreateHashCollision', // impossible hash collision on generating address
78
'SuicidesMixingCoinbase', // sucides to the coinbase, since we run a blockLevel we create coinbase account.
@@ -29,6 +30,7 @@ const skip = [
2930
'bcSimpleTransitionTest', // HF stuff
3031
'loop-mul' // ain't nobody need loops
3132
]
33+
// TODO: skip BlockchainTests/GeneralStateTests/stMemoryStressTest/*
3234

3335
if (argv.r) {
3436
randomized(argv.r, argv.v)
@@ -76,20 +78,34 @@ function randomized (stateTest) {
7678
})
7779
}
7880

79-
function runTests (name, args, cb) {
80-
// setup skipe function
81-
args.testFn = (name) => {
82-
return skip.includes(name)
81+
function runTests (name, runnerArgs, cb) {
82+
let testGetterArgs = argv
83+
84+
// setup skip function
85+
if (name === 'BlockchainTests') {
86+
const forkFilter = new RegExp(`${FORK_CONFIG}$`)
87+
testGetterArgs.skipFn = (name) => {
88+
return ((forkFilter.test(name) === false) || skip.includes(name))
89+
}
90+
} else {
91+
testGetterArgs.skipFn = (name) => {
92+
return skip.includes(name)
93+
}
8394
}
8495

96+
97+
runnerArgs.forkConfig = FORK_CONFIG
98+
//runnerArgs.debugging = true; // for BlockchainTests
99+
//runnerArgs.vmtrace = true; // for VMTests
100+
85101
tape(name, t => {
86102
const runner = require(`./${name}Runner.js`)
87103
testing.getTestsFromArgs(name, (fileName, testName, test) => {
88104
return new Promise((resolve, reject) => {
89105
t.comment(`file: ${fileName} test: ${testName}`)
90-
runner(args, test, t, resolve)
106+
runner(runnerArgs, test, t, resolve)
91107
}).catch(err => console.log(err))
92-
}, argv).then(() => {
108+
}, testGetterArgs).then(() => {
93109
t.end()
94110
})
95111
})
@@ -100,8 +116,8 @@ function runAll () {
100116
require('./cacheTest.js')
101117
require('./genesishashes.js')
102118
async.series([
103-
runTests.bind(this, 'BlockchainTests', {}),
104-
runTests.bind(this, 'StateTests', {}),
105-
runTests.bind(this, 'VMTests', {})
119+
runTests.bind(this, 'VMTests', {}),
120+
//runTests.bind(this, 'StateTests', {}), // TODO: update StateTestsRunnner for GeneralStateTests
121+
runTests.bind(this, 'BlockchainTests', {})
106122
])
107123
}

0 commit comments

Comments
 (0)