Skip to content

Commit

Permalink
add support for testing custom state tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jwasinger committed Sep 21, 2017
1 parent a1f58b0 commit 2269a7f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ curl https://gist.githubusercontent.com/jwasinger/e7004e82426ff0a7137a88d273f118
python utils/diffTestOutput.py output-wip-byzantium.txt output-master.txt
```

Run a state test from a specified source file not under the ``tests`` directory:
`node ./tests/tester -s --stateTestSource='{path_to_file}'`

For a wider picture about how to use tests to implement EIPs you can have a look at this [reddit post](https://www.reddit.com/r/ethereum/comments/6kc5g3/ethereumjs_team_is_seeking_contributors/)
or the associated YouTube video introduction to [core development with Ethereumjs-vm](https://www.youtube.com/watch?v=L0BVDl6HZzk&feature=youtu.be).

Expand Down
53 changes: 36 additions & 17 deletions tests/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ function runTests (name, runnerArgs, cb) {
testGetterArgs.excludeDir = argv.excludeDir
testGetterArgs.testsPath = argv.testsPath

testGetterArgs.stateTestSource = argv.stateTestSource

runnerArgs.forkConfig = FORK_CONFIG
runnerArgs.jsontrace = argv.jsontrace
runnerArgs.debug = argv.debug // for BlockchainTests
Expand All @@ -155,25 +157,42 @@ function runTests (name, runnerArgs, cb) {

// runnerArgs.vmtrace = true; // for VMTests

tape(name, t => {
const runner = require(`./${name}Runner.js`)
testing.getTestsFromArgs(name, (fileName, testName, test) => {
return new Promise((resolve, reject) => {
if (name === 'VMTests') {
// suppress some output of VMTests
// t.comment(`file: ${fileName} test: ${testName}`)
test.fileName = fileName
test.testName = testName
runner(runnerArgs, test, t, resolve)
} else {
t.comment(`file: ${fileName} test: ${testName}`)
runner(runnerArgs, test, t, resolve)
if (argv.stateTestSource) {
const stateTestRunner = require('./GeneralStateTestsRunner.js')
let fileName = argv.stateTestSource
tape(name, t => {
testing.getTestFromSource(fileName, (err, test) => {
if (err) {
return t.fail(err)
}
}).catch(err => console.log(err))
}, testGetterArgs).then(() => {
t.end()

t.comment(`file: ${fileName} test: ${test.testName}`)
stateTestRunner(runnerArgs, test, t, () => {
t.end()
})
})
})
})
} else {
tape(name, t => {
const runner = require(`./${name}Runner.js`)
testing.getTestsFromArgs(name, (fileName, testName, test) => {
return new Promise((resolve, reject) => {
if (name === 'VMTests') {
// suppress some output of VMTests
// t.comment(`file: ${fileName} test: ${testName}`)
test.fileName = fileName
test.testName = testName
runner(runnerArgs, test, t, resolve)
} else {
t.comment(`file: ${fileName} test: ${testName}`)
runner(runnerArgs, test, t, resolve)
}
}).catch(err => console.log(err))
}, testGetterArgs).then(() => {
t.end()
})
})
}
}

function runAll () {
Expand Down

0 comments on commit 2269a7f

Please sign in to comment.