| 233 | } |
| 234 | |
| 235 | func (t *BlockTest) validatePostState(statedb *state.StateDB) error { |
| 236 | // validate post state accounts in test file against what we have in state db |
| 237 | for addr, acct := range t.json.Post { |
| 238 | // address is indirectly verified by the other fields, as it's the db key |
| 239 | code2 := statedb.GetCode(addr) |
| 240 | balance2 := statedb.GetBalance(addr) |
| 241 | nonce2 := statedb.GetNonce(addr) |
| 242 | if !bytes.Equal(code2, acct.Code) { |
| 243 | return fmt.Errorf("account code mismatch for addr: %s want: %v have: %s", addr, acct.Code, hex.EncodeToString(code2)) |
| 244 | } |
| 245 | if balance2.Cmp(acct.Balance) != 0 { |
| 246 | return fmt.Errorf("account balance mismatch for addr: %s, want: %d, have: %d", addr, acct.Balance, balance2) |
| 247 | } |
| 248 | if nonce2 != acct.Nonce { |
| 249 | return fmt.Errorf("account nonce mismatch for addr: %s want: %d have: %d", addr, acct.Nonce, nonce2) |
| 250 | } |
| 251 | } |
| 252 | return nil |
| 253 | } |
| 254 | |
| 255 | func (t *BlockTest) validateImportedHeaders(cm *core.BlockChain, validBlocks []btBlock) error { |
| 256 | // to get constant lookup when verifying block headers by hash (some tests have many blocks) |