Skip to content

Commit c8a2202

Browse files
authored
cmd/evm: validate blockchain tests poststate account storage (#28443)
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
1 parent 8b78d6a commit c8a2202

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/block_test_util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ func (t *BlockTest) validatePostState(statedb *state.StateDB) error {
330330
if nonce2 != acct.Nonce {
331331
return fmt.Errorf("account nonce mismatch for addr: %s want: %d have: %d", addr, acct.Nonce, nonce2)
332332
}
333+
for k, v := range acct.Storage {
334+
v2 := statedb.GetState(addr, k)
335+
if v2 != v {
336+
return fmt.Errorf("account storage mismatch for addr: %s, slot: %x, want: %x, have: %x", addr, k, v, v2)
337+
}
338+
}
333339
}
334340
return nil
335341
}

0 commit comments

Comments
 (0)