diff --git a/cmd/evm/staterunner.go b/cmd/evm/staterunner.go index a29c4b18f..85931f040 100644 --- a/cmd/evm/staterunner.go +++ b/cmd/evm/staterunner.go @@ -107,6 +107,13 @@ func runStateTest(fname string, cfg vm.Config, jsonOut, dump bool) error { // Run the test and aggregate the result result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true} test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) { + if state != nil { + root := state.IntermediateRoot(false) + result.Root = &root + if jsonOut { + fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root) + } + } if err != nil { // Test failed, mark as so and dump any state to aid debugging result.Pass, result.Error = false, err.Error() @@ -114,12 +121,6 @@ func runStateTest(fname string, cfg vm.Config, jsonOut, dump bool) error { dump := state.RawDump(nil) result.State = &dump } - } else { - root := state.IntermediateRoot(false) - result.Root = &root - if jsonOut { - fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root) - } } }) results = append(results, *result)