File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,9 @@ package cuckoo
22
33import (
44 "bufio"
5- "crypto/rand"
65 "fmt"
7- "io"
86 "math"
7+ "math/rand"
98 "os"
109 "testing"
1110
@@ -104,14 +103,13 @@ func TestFilter_LookupLarge(t *testing.T) {
104103}
105104
106105func TestFilter_Insert (t * testing.T ) {
107- const cap = 10000
108- filter := NewFilter (cap )
109-
110- var hash [32 ]byte
106+ filter := NewFilter (10000 )
107+ rng := rand .New (rand .NewSource (int64 (42 )))
111108
109+ hash := make ([]byte , 32 )
112110 for i := 0 ; i < 100 ; i ++ {
113- io . ReadFull ( rand . Reader , hash [:] )
114- filter .Insert (hash [:] )
111+ rng . Read ( hash )
112+ filter .Insert (hash )
115113 }
116114
117115 if got , want := filter .Count (), uint (100 ); got != want {
@@ -134,9 +132,10 @@ func BenchmarkFilter_Reset(b *testing.B) {
134132func benchmarkKeys (b * testing.B , size int ) [][]byte {
135133 b .Helper ()
136134 keys := make ([][]byte , size )
135+ rng := rand .New (rand .NewSource (int64 (size )))
137136 for i := range keys {
138137 keys [i ] = make ([]byte , 32 )
139- if _ , err := io . ReadFull ( rand . Reader , keys [i ]); err != nil {
138+ if _ , err := rng . Read ( keys [i ]); err != nil {
140139 b .Error (err )
141140 }
142141 }
You can’t perform that action at this time.
0 commit comments