Skip to content

Commit

Permalink
trie: fix random test generator early terminate (ethereum#28590)
Browse files Browse the repository at this point in the history
This change fixes a minor bug in the `randTest.Generate` function, which caused the `quick.Check` to be a no-op.
  • Loading branch information
weiihann committed Nov 25, 2023
1 parent 2a20130 commit 333dd95
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ func TestRandomCases(t *testing.T) {
// Instances of this test are created by Generate.
type randTest []randTestStep

// compile-time interface check
var _ quick.Generator = (randTest)(nil)

type randTestStep struct {
op int
key []byte // for opUpdate, opDelete, opGet
Expand All @@ -394,7 +397,7 @@ const (
func (randTest) Generate(r *rand.Rand, size int) reflect.Value {
var finishedFn = func() bool {
size--
return size > 0
return size == 0
}
return reflect.ValueOf(generateSteps(finishedFn, r))
}
Expand Down

0 comments on commit 333dd95

Please sign in to comment.