From 333dd956bfdf1d5086d38cceedbba25a366fb6ac Mon Sep 17 00:00:00 2001 From: Ng Wei Han <47109095+weiihann@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:56:22 +0800 Subject: [PATCH] trie: fix random test generator early terminate (#28590) This change fixes a minor bug in the `randTest.Generate` function, which caused the `quick.Check` to be a no-op. --- trie/trie_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trie/trie_test.go b/trie/trie_test.go index 6af0f67b9..c5bd3faf5 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -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 @@ -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)) }