@@ -119,19 +119,19 @@ func TestInsertTNode(t *testing.T) {
119119 assert := assert .New (t )
120120 ctrie := New (nil )
121121
122- for i := 0 ; i < 100000 ; i ++ {
122+ for i := 0 ; i < 10000 ; i ++ {
123123 ctrie .Insert ([]byte (strconv .Itoa (i )), i )
124124 }
125125
126- for i := 0 ; i < 50000 ; i ++ {
126+ for i := 0 ; i < 5000 ; i ++ {
127127 ctrie .Remove ([]byte (strconv .Itoa (i )))
128128 }
129129
130- for i := 0 ; i < 100000 ; i ++ {
130+ for i := 0 ; i < 10000 ; i ++ {
131131 ctrie .Insert ([]byte (strconv .Itoa (i )), i )
132132 }
133133
134- for i := 0 ; i < 100000 ; i ++ {
134+ for i := 0 ; i < 10000 ; i ++ {
135135 val , ok := ctrie .Lookup ([]byte (strconv .Itoa (i )))
136136 assert .True (ok )
137137 assert .Equal (i , val )
@@ -145,14 +145,14 @@ func TestConcurrency(t *testing.T) {
145145 wg .Add (2 )
146146
147147 go func () {
148- for i := 0 ; i < 100000 ; i ++ {
148+ for i := 0 ; i < 10000 ; i ++ {
149149 ctrie .Insert ([]byte (strconv .Itoa (i )), i )
150150 }
151151 wg .Done ()
152152 }()
153153
154154 go func () {
155- for i := 0 ; i < 100000 ; i ++ {
155+ for i := 0 ; i < 10000 ; i ++ {
156156 val , ok := ctrie .Lookup ([]byte (strconv .Itoa (i )))
157157 if ok {
158158 assert .Equal (i , val )
@@ -161,7 +161,7 @@ func TestConcurrency(t *testing.T) {
161161 wg .Done ()
162162 }()
163163
164- for i := 0 ; i < 100000 ; i ++ {
164+ for i := 0 ; i < 10000 ; i ++ {
165165 time .Sleep (5 )
166166 ctrie .Remove ([]byte (strconv .Itoa (i )))
167167 }
@@ -291,7 +291,11 @@ func TestIterator(t *testing.T) {
291291 assert .Equal (exp , entry .Value )
292292 }
293293 close (cancel )
294- <- iter // Drain anything already put on the channel
294+ // Drain anything already put on the channel. Since select chooses a
295+ // pseudo-random case, we must attempt to drain for every item.
296+ for _ = range expected {
297+ <- iter
298+ }
295299 _ , ok = <- iter
296300 assert .False (ok )
297301}
0 commit comments