MCPcopy Create free account
hub / github.com/CPChain/chain / validatePostState

Method validatePostState

tests/block_test_util.go:235–253  ·  view source on GitHub ↗
(statedb *state.StateDB)

Source from the content-addressed store, hash-verified

233}
234
235func (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
255func (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)

Callers 1

RunMethod · 0.95

Calls 5

CmpMethod · 0.80
GetCodeMethod · 0.65
GetBalanceMethod · 0.65
GetNonceMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected