forked from forks/go-ethereum
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.
This commit is contained in:
parent
e75f354ae7
commit
5065e6c935
1 changed files with 6 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue