Skip to content

Commit

Permalink
triedb/pathdb: fix tester generator (#30972)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ceyonur authored Jan 7, 2025
1 parent e75f354 commit 5065e6c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion triedb/pathdb/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@ func (t *tester) generate(parent common.Hash) (common.Hash, *trienode.MergedNode
dirties = make(map[common.Hash]struct{})
)
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:
// account creation
addr := testrand.Address()
Expand Down

0 comments on commit 5065e6c

Please sign in to comment.