triedb/pathdb: fix tester generator (#30972)

This change fixes is a rare bug in test generator: If the run is very unlucky it
can use `modifyAccountOp` / `deleteAccountOp` without creating any
account, leading to have a trie root same as the parent.

This change makes the first operation always be a creation.
pull/31000/head
Ceyhun Onur 3 weeks ago committed by GitHub
parent e75f354ae7
commit 5065e6c935
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      triedb/pathdb/database_test.go

@ -222,7 +222,12 @@ func (t *tester) generate(parent common.Hash) (common.Hash, *trienode.MergedNode
dirties = make(map[common.Hash]struct{}) dirties = make(map[common.Hash]struct{})
) )
for i := 0; i < 20; i++ { for i := 0; i < 20; i++ {
switch rand.Intn(opLen) { // Start with account creation always
op := createAccountOp
if i > 0 {
op = rand.Intn(opLen)
}
switch op {
case createAccountOp: case createAccountOp:
// account creation // account creation
addr := testrand.Address() addr := testrand.Address()

Loading…
Cancel
Save