Skip to content

Commit

Permalink
tests: refactor TestState to dedupe walk callback
Browse files Browse the repository at this point in the history
Minor refactoring.
  • Loading branch information
meowsbits committed Nov 20, 2019
1 parent 3a4a3d0 commit b8ced9e
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions tests/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,25 @@ func TestState(t *testing.T) {
//st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/ConstantinopleFix/0`, "bug in test")
//st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/ConstantinopleFix/3`, "bug in test")

st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
for _, subtest := range test.Subtests() {
subtest := subtest
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
name := name + "/" + key
t.Run(key, func(t *testing.T) {
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
_, err := test.Run(subtest, vmconfig)
return st.checkFailure(t, name, err)
})
})
}
})
// For Istanbul, older tests were moved into LegacyTests
st.walk(t, legacyStateTestDir, func(t *testing.T, name string, test *StateTest) {
for _, subtest := range test.Subtests() {
subtest := subtest
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
name := name + "/" + key
t.Run(key, func(t *testing.T) {
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
_, err := test.Run(subtest, vmconfig)
return st.checkFailure(t, name, err)
for _, dir := range []string{
stateTestDir,
legacyStateTestDir,
} {
st.walk(t, dir, func(t *testing.T, name string, test *StateTest) {
for _, subtest := range test.Subtests() {
subtest := subtest
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
name := name + "/" + key
t.Run(key, func(t *testing.T) {
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
_, err := test.Run(subtest, vmconfig)
return st.checkFailure(t, name, err)
})
})
})
}
})
}
})
}
}

// Transactions with gasLimit above this value will not get a VM trace on failure.
Expand Down

0 comments on commit b8ced9e

Please sign in to comment.