Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to test a custom state test #202

Merged
merged 6 commits into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,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 --customStateTest='{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 @@ -185,6 +185,8 @@ function runTests (name, runnerArgs, cb) {
testGetterArgs.excludeDir = argv.excludeDir
testGetterArgs.testsPath = argv.testsPath

testGetterArgs.customStateTest = argv.customStateTest

runnerArgs.forkConfig = FORK_CONFIG
runnerArgs.jsontrace = argv.jsontrace
runnerArgs.debug = argv.debug // for BlockchainTests
Expand All @@ -196,25 +198,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.customStateTest) {
const stateTestRunner = require('./GeneralStateTestsRunner.js')
let fileName = argv.customStateTest
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