diff --git a/db/seg/compress_fuzz_test.go b/db/seg/compress_fuzz_test.go index f4f2192085f..5e17d47e8bb 100644 --- a/db/seg/compress_fuzz_test.go +++ b/db/seg/compress_fuzz_test.go @@ -40,7 +40,7 @@ func FuzzCompress(f *testing.F) { if pos[i] == 0 { continue } - next := min(j+int(pos[i]*10), len(x)-1) + next := min(j+int(pos[i])*10, len(x)-1) bbb := x[j:next] a = append(a, bbb) j = next diff --git a/db/seg/decompress_fuzz_test.go b/db/seg/decompress_fuzz_test.go index 21871c3b91b..067998e820b 100644 --- a/db/seg/decompress_fuzz_test.go +++ b/db/seg/decompress_fuzz_test.go @@ -41,7 +41,7 @@ func FuzzDecompressMatch(f *testing.F) { if pos[i] == 0 { continue } - next := min(j+int(pos[i]*10), len(x)-1) + next := min(j+int(pos[i])*10, len(x)-1) bbb := x[j:next] a = append(a, bbb) j = next diff --git a/db/seg/patricia/patricia_fuzz_test.go b/db/seg/patricia/patricia_fuzz_test.go index 6e66ab72e46..8337e12b6e0 100644 --- a/db/seg/patricia/patricia_fuzz_test.go +++ b/db/seg/patricia/patricia_fuzz_test.go @@ -61,6 +61,9 @@ func FuzzLongestMatch(f *testing.F) { if len(keys) == 0 { return } + // keys indexes the generated match data below, so map iteration order + // would make the same fuzz input build a different test string each run. + slices.Sort(keys) var data []byte for i := 0; i < 4*(len(test)/4); i += 4 { keyIdx := int(binary.BigEndian.Uint32(test[i : i+4]))