Skip to content

Commit

Permalink
cmd/evm: validate blockchain tests poststate account storage (#28443)
Browse files Browse the repository at this point in the history
This PR verifies the accounts' storage as specified in a blockchain test's postState field

The expect-section, it does really only check that the test works. It's meant for the test-author to verify that "If the test does what it's supposed to, then the nonce of X should be 2, and the slot Y at Z should be 0x123.

    This expect-section is not exhaustive (not full post-state)
    It is also not auto-generated, but put there manually by the author.

We can still check it, as a test-sanity-check, in geth
  • Loading branch information
danceratopz authored Nov 17, 2023
1 parent 8b78d6a commit c8a2202
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/block_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ func (t *BlockTest) validatePostState(statedb *state.StateDB) error {
if nonce2 != acct.Nonce {
return fmt.Errorf("account nonce mismatch for addr: %s want: %d have: %d", addr, acct.Nonce, nonce2)
}
for k, v := range acct.Storage {
v2 := statedb.GetState(addr, k)
if v2 != v {
return fmt.Errorf("account storage mismatch for addr: %s, slot: %x, want: %x, have: %x", addr, k, v, v2)
}
}
}
return nil
}
Expand Down

0 comments on commit c8a2202

Please sign in to comment.