From 9e5f03b6c487175cc5aa1224e5e12fd573f483a7 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 27 Jun 2017 15:57:06 +0200 Subject: core/state: access trie through Database interface, track errors (#14589) With this commit, core/state's access to the underlying key/value database is mediated through an interface. Database errors are tracked in StateDB and returned by CommitTo or the new Error method. Motivation for this change: We can remove the light client's duplicated copy of core/state. The light client now supports node iteration, so tracing and storage enumeration can work with the light client (not implemented in this commit). --- core/blockchain_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core/blockchain_test.go') diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 7505208e1..371522ab7 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -131,7 +131,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error { } return err } - statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.chainDb) + statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.stateCache) if err != nil { return err } @@ -148,7 +148,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error { blockchain.mu.Lock() WriteTd(blockchain.chainDb, block.Hash(), block.NumberU64(), new(big.Int).Add(block.Difficulty(), blockchain.GetTdByHash(block.ParentHash()))) WriteBlock(blockchain.chainDb, block) - statedb.Commit(false) + statedb.CommitTo(blockchain.chainDb, false) blockchain.mu.Unlock() } return nil @@ -1131,7 +1131,7 @@ func TestEIP161AccountRemoval(t *testing.T) { if _, err := blockchain.InsertChain(types.Blocks{blocks[0]}); err != nil { t.Fatal(err) } - if !blockchain.stateCache.Exist(theAddr) { + if st, _ := blockchain.State(); !st.Exist(theAddr) { t.Error("expected account to exist") } @@ -1139,7 +1139,7 @@ func TestEIP161AccountRemoval(t *testing.T) { if _, err := blockchain.InsertChain(types.Blocks{blocks[1]}); err != nil { t.Fatal(err) } - if blockchain.stateCache.Exist(theAddr) { + if st, _ := blockchain.State(); st.Exist(theAddr) { t.Error("account should not exist") } @@ -1147,7 +1147,7 @@ func TestEIP161AccountRemoval(t *testing.T) { if _, err := blockchain.InsertChain(types.Blocks{blocks[2]}); err != nil { t.Fatal(err) } - if blockchain.stateCache.Exist(theAddr) { + if st, _ := blockchain.State(); st.Exist(theAddr) { t.Error("account should not exist") } } -- cgit v1.2.3