diff options
author | Martin Holst Swende <martin@swende.se> | 2017-09-05 17:24:26 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-09-05 17:24:26 +0800 |
commit | 8cab3ab4350fe06f5dd1e9bb9ce5f559c08bc4cf (patch) | |
tree | 6267317ecc6cdb573868d71880fbe88f1db4037a /tests | |
parent | 504278e8398ef787d4f6f73178afa342a31a88ed (diff) | |
download | go-tangerine-8cab3ab4350fe06f5dd1e9bb9ce5f559c08bc4cf.tar.gz go-tangerine-8cab3ab4350fe06f5dd1e9bb9ce5f559c08bc4cf.tar.zst go-tangerine-8cab3ab4350fe06f5dd1e9bb9ce5f559c08bc4cf.zip |
cmd/evm: adds ability to run individual state test file (#14998)
* cmd/evm: adds ability to run individual state test file
* cmd/evm: Fix statetest runner to be more json friendly
* cmd/evm, tests: minor polishes, dump state on fail
Diffstat (limited to 'tests')
-rw-r--r-- | tests/state_test.go | 3 | ||||
-rw-r--r-- | tests/state_test_util.go | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/tests/state_test.go b/tests/state_test.go index 4b6ba8b31..1fb7f5908 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -50,7 +50,8 @@ func TestState(t *testing.T) { t.Skip("constantinople not supported yet") } withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error { - return st.checkFailure(t, name, test.Run(subtest, vmconfig)) + _, err := test.Run(subtest, vmconfig) + return st.checkFailure(t, name, err) }) }) } diff --git a/tests/state_test_util.go b/tests/state_test_util.go index ecaa6c668..64bf09cb4 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -120,10 +120,10 @@ func (t *StateTest) Subtests() []StateSubtest { } // Run executes a specific subtest. -func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) error { +func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateDB, error) { config, ok := Forks[subtest.Fork] if !ok { - return UnsupportedForkError{subtest.Fork} + return nil, UnsupportedForkError{subtest.Fork} } block, _ := t.genesis(config).ToBlock() db, _ := ethdb.NewMemDatabase() @@ -132,7 +132,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) error { post := t.json.Post[subtest.Fork][subtest.Index] msg, err := t.json.Tx.toMessage(post) if err != nil { - return err + return nil, err } context := core.NewEVMContext(msg, block.Header(), nil, &t.json.Env.Coinbase) context.GetHash = vmTestBlockHash @@ -145,13 +145,13 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) error { statedb.RevertToSnapshot(snapshot) } if logs := rlpHash(statedb.Logs()); logs != common.Hash(post.Logs) { - return fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs) + return statedb, fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs) } root, _ := statedb.CommitTo(db, config.IsEIP158(block.Number())) if root != common.Hash(post.Root) { - return fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root) + return statedb, fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root) } - return nil + return statedb, nil } func (t *StateTest) gasLimit(subtest StateSubtest) uint64 { |