diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-02-16 18:37:00 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-02-16 18:37:00 +0800 |
commit | b8d59d9c985feed9ec1d8851f65517c7e5c09deb (patch) | |
tree | 5ceb6da2603a0fceb849e9ecd4aea641c6ebc816 /core/state/sync_test.go | |
parent | 151c7bef41ed96d9aace3dba235ad2db5fe26e03 (diff) | |
download | go-tangerine-b8d59d9c985feed9ec1d8851f65517c7e5c09deb.tar.gz go-tangerine-b8d59d9c985feed9ec1d8851f65517c7e5c09deb.tar.zst go-tangerine-b8d59d9c985feed9ec1d8851f65517c7e5c09deb.zip |
core/state, trie: switch iterator panics to error fields
Diffstat (limited to 'core/state/sync_test.go')
-rw-r--r-- | core/state/sync_test.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/state/sync_test.go b/core/state/sync_test.go index 727a276a5..a2a1edbdb 100644 --- a/core/state/sync_test.go +++ b/core/state/sync_test.go @@ -18,7 +18,6 @@ package state import ( "bytes" - "fmt" "math/big" "testing" @@ -97,28 +96,23 @@ func checkStateAccounts(t *testing.T, db ethdb.Database, root common.Hash, accou } } -// checkStateConsistency checks that all nodes in a state trie and indeed present. -func checkStateConsistency(db ethdb.Database, root common.Hash) (failure error) { - // Capture any panics by the iterator - defer func() { - if r := recover(); r != nil { - failure = fmt.Errorf("%v", r) - } - }() +// checkStateConsistency checks that all nodes in a state trie are indeed present. +func checkStateConsistency(db ethdb.Database, root common.Hash) error { // Remove any potentially cached data from the test state creation or previous checks trie.ClearGlobalCache() // Create and iterate a state trie rooted in a sub-node if _, err := db.Get(root.Bytes()); err != nil { - return + return nil // Consider a non existent state consistent } state, err := New(root, db) if err != nil { - return + return err } - for it := NewNodeIterator(state); it.Next(); { + it := NewNodeIterator(state) + for it.Next() { } - return nil + return it.Error } // Tests that an empty state is not scheduled for syncing. |