diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-02-19 21:41:57 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-02-19 21:41:57 +0800 |
commit | f8d98f7fcd08bd2eff36d5366ac2a14b52255d57 (patch) | |
tree | 99111d4f80ee4c436c99813ef8ffe7a7b16ee8ce /tests/state_test_util.go | |
parent | c305005d831eccf9d65c7b55f817390d2334e666 (diff) | |
parent | 5b283663b40dbc06c56cc481ef90f4365ab85724 (diff) | |
download | dexon-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar dexon-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.gz dexon-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.bz2 dexon-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.lz dexon-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.xz dexon-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.tar.zst dexon-f8d98f7fcd08bd2eff36d5366ac2a14b52255d57.zip |
Merge pull request #2116 from obscuren/homestead
core, core/vm: consensus changes necessary for the homestead release
Diffstat (limited to 'tests/state_test_util.go')
-rw-r--r-- | tests/state_test_util.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 352fe3570..7d1701ff2 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -123,17 +123,17 @@ func runStateTests(tests map[string]VmTest, skipTests []string) error { } for name, test := range tests { - if skipTest[name] { + if skipTest[name] /*|| name != "callcodecallcode_11" */ { glog.Infoln("Skipping state test", name) - return nil + continue } - //fmt.Println("StateTest name:", name) + //fmt.Println("StateTest:", name) if err := runStateTest(test); err != nil { return fmt.Errorf("%s: %s\n", name, err.Error()) } - glog.Infoln("State test passed: ", name) + //glog.Infoln("State test passed: ", name) //fmt.Println(string(statedb.Dump())) } return nil @@ -182,13 +182,16 @@ func runStateTest(test VmTest) error { // check post state for addr, account := range test.Post { obj := statedb.GetStateObject(common.HexToAddress(addr)) + if obj == nil { + return fmt.Errorf("did not find expected post-state account: %s", addr) + } if obj.Balance().Cmp(common.Big(account.Balance)) != 0 { - return fmt.Errorf("(%x) balance failed. Expected %v, got %v => %v\n", obj.Address().Bytes()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(common.Big(account.Balance), obj.Balance())) + return fmt.Errorf("(%x) balance failed. Expected: %v have: %v\n", obj.Address().Bytes()[:4], common.String2Big(account.Balance), obj.Balance()) } if obj.Nonce() != common.String2Big(account.Nonce).Uint64() { - return fmt.Errorf("(%x) nonce failed. Expected %v, got %v\n", obj.Address().Bytes()[:4], account.Nonce, obj.Nonce()) + return fmt.Errorf("(%x) nonce failed. Expected: %v have: %v\n", obj.Address().Bytes()[:4], account.Nonce, obj.Nonce()) } for addr, value := range account.Storage { @@ -196,14 +199,14 @@ func runStateTest(test VmTest) error { vexp := common.HexToHash(value) if v != vexp { - return fmt.Errorf("(%x: %s) storage failed. Expected %x, got %x (%v %v)\n", obj.Address().Bytes()[0:4], addr, vexp, v, vexp.Big(), v.Big()) + return fmt.Errorf("storage failed:\n%x: %s:\nexpected: %x\nhave: %x\n(%v %v)\n", obj.Address().Bytes(), addr, vexp, v, vexp.Big(), v.Big()) } } } root, _ := statedb.Commit() if common.HexToHash(test.PostStateRoot) != root { - return fmt.Errorf("Post state root error. Expected %s, got %x", test.PostStateRoot, root) + return fmt.Errorf("Post state root error. Expected: %s have: %x", test.PostStateRoot, root) } // check logs @@ -232,7 +235,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, vm.Log } // Set pre compiled contracts vm.Precompiled = vm.PrecompiledContracts() - + vm.Debug = false snapshot := statedb.Copy() gaspool := new(core.GasPool).AddGas(common.Big(env["currentGasLimit"])) |