checkStateAccounts cross references a reconstructed state with an expected account array.
(t *testing.T, db database.Database, root common.Hash, accounts []*testAccount)
| 69 | // checkStateAccounts cross references a reconstructed state with an expected |
| 70 | // account array. |
| 71 | func checkStateAccounts(t *testing.T, db database.Database, root common.Hash, accounts []*testAccount) { |
| 72 | // Check root availability and state contents |
| 73 | state, err := New(root, NewDatabase(db)) |
| 74 | if err != nil { |
| 75 | t.Fatalf("failed to create state trie at %x: %v", root, err) |
| 76 | } |
| 77 | if err := checkStateConsistency(db, root); err != nil { |
| 78 | t.Fatalf("inconsistent state trie at %x: %v", root, err) |
| 79 | } |
| 80 | for i, acc := range accounts { |
| 81 | if balance := state.GetBalance(acc.address); balance.Cmp(acc.balance) != 0 { |
| 82 | t.Errorf("account %d: balance mismatch: have %v, want %v", i, balance, acc.balance) |
| 83 | } |
| 84 | if nonce := state.GetNonce(acc.address); nonce != acc.nonce { |
| 85 | t.Errorf("account %d: nonce mismatch: have %v, want %v", i, nonce, acc.nonce) |
| 86 | } |
| 87 | if code := state.GetCode(acc.address); !bytes.Equal(code, acc.code) { |
| 88 | t.Errorf("account %d: code mismatch: have %x, want %x", i, code, acc.code) |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // checkTrieConsistency checks that all nodes in a (sub-)trie are indeed present. |
| 94 | func checkTrieConsistency(db database.Database, root common.Hash) error { |
no test coverage detected