diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-01 19:34:38 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-01 19:34:38 +0800 |
commit | 49ae53850622f3ea051184dccc867fbfec4c9ecb (patch) | |
tree | 669f4b161773c9b95c6631e83a3c34d446c33fef /tests | |
parent | 581c0901af22d678aedd9eefae6144582c23e1a0 (diff) | |
parent | c1a352c1085baa5c5f7650d331603bbb5532dea4 (diff) | |
download | dexon-49ae53850622f3ea051184dccc867fbfec4c9ecb.tar dexon-49ae53850622f3ea051184dccc867fbfec4c9ecb.tar.gz dexon-49ae53850622f3ea051184dccc867fbfec4c9ecb.tar.bz2 dexon-49ae53850622f3ea051184dccc867fbfec4c9ecb.tar.lz dexon-49ae53850622f3ea051184dccc867fbfec4c9ecb.tar.xz dexon-49ae53850622f3ea051184dccc867fbfec4c9ecb.tar.zst dexon-49ae53850622f3ea051184dccc867fbfec4c9ecb.zip |
Merge pull request #1405 from fjl/lean-trie
core, trie: new trie
Diffstat (limited to 'tests')
-rw-r--r-- | tests/block_test_util.go | 12 | ||||
-rw-r--r-- | tests/state_test_util.go | 8 |
2 files changed, 10 insertions, 10 deletions
diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 3ca00bae8..33577cf55 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -253,13 +253,13 @@ func (t *BlockTest) InsertPreState(ethereum *eth.Ethereum) (*state.StateDB, erro statedb.SetState(common.HexToAddress(addrString), common.HexToHash(k), common.HexToHash(v)) } } - // sync objects to trie - statedb.SyncObjects() - // sync trie to disk - statedb.Sync() - if !bytes.Equal(t.Genesis.Root().Bytes(), statedb.Root().Bytes()) { - return nil, fmt.Errorf("computed state root does not match genesis block %x %x", t.Genesis.Root().Bytes()[:4], statedb.Root().Bytes()[:4]) + root, err := statedb.Commit() + if err != nil { + return nil, fmt.Errorf("error writing state: %v", err) + } + if t.Genesis.Root() != root { + return nil, fmt.Errorf("computed state root does not match genesis block: genesis=%x computed=%x", t.Genesis.Root().Bytes()[:4], root.Bytes()[:4]) } return statedb, nil } diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 95ecdd0a8..3d8dfca31 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -201,9 +201,9 @@ func runStateTest(test VmTest) error { } } - statedb.Sync() - if common.HexToHash(test.PostStateRoot) != statedb.Root() { - return fmt.Errorf("Post state root error. Expected %s, got %x", test.PostStateRoot, statedb.Root()) + root, _ := statedb.Commit() + if common.HexToHash(test.PostStateRoot) != root { + return fmt.Errorf("Post state root error. Expected %s, got %x", test.PostStateRoot, root) } // check logs @@ -247,7 +247,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state. if core.IsNonceErr(err) || core.IsInvalidTxErr(err) || state.IsGasLimitErr(err) { statedb.Set(snapshot) } - statedb.SyncObjects() + statedb.Commit() return ret, vmenv.state.Logs(), vmenv.Gas, err } |