diff options
Diffstat (limited to 'whisper/whisperv5/filter_test.go')
-rw-r--r-- | whisper/whisperv5/filter_test.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/whisper/whisperv5/filter_test.go b/whisper/whisperv5/filter_test.go index 5bf607ccc..d69fb40db 100644 --- a/whisper/whisperv5/filter_test.go +++ b/whisper/whisperv5/filter_test.go @@ -43,7 +43,7 @@ func InitDebugTest(i int64) { type FilterTestCase struct { f *Filter - id uint32 + id string alive bool msgCnt int } @@ -100,14 +100,17 @@ func TestInstallFilters(t *testing.T) { filters := NewFilters(w) tst := generateTestCases(t, SizeTestFilters) - var j uint32 + var err error + var j string for i := 0; i < SizeTestFilters; i++ { - j = filters.Install(tst[i].f) + j, err = filters.Install(tst[i].f) + if err != nil { + t.Fatalf("seed %d: failed to install filter: %s", seed, err) + } tst[i].id = j - } - - if j < SizeTestFilters-1 { - t.Fatalf("seed %d: wrong index %d", seed, j) + if len(j) != 40 { + t.Fatalf("seed %d: wrong filter id size [%d]", seed, len(j)) + } } for _, testCase := range tst { @@ -519,17 +522,25 @@ func TestWatchers(t *testing.T) { var i int var j uint32 var e *Envelope + var x, firstID string + var err error w := New() filters := NewFilters(w) tst := generateTestCases(t, NumFilters) for i = 0; i < NumFilters; i++ { tst[i].f.Src = nil - j = filters.Install(tst[i].f) - tst[i].id = j + x, err = filters.Install(tst[i].f) + if err != nil { + t.Fatalf("failed to install filter with seed %d: %s.", seed, err) + } + tst[i].id = x + if len(firstID) == 0 { + firstID = x + } } - last := j + lastID := x var envelopes [NumMessages]*Envelope for i = 0; i < NumMessages; i++ { @@ -571,9 +582,9 @@ func TestWatchers(t *testing.T) { // another round with a cloned filter clone := cloneFilter(tst[0].f) - filters.Uninstall(last) + filters.Uninstall(lastID) total = 0 - last = NumFilters - 1 + last := NumFilters - 1 tst[last].f = clone filters.Install(clone) for i = 0; i < NumFilters; i++ { @@ -640,7 +651,7 @@ func TestWatchers(t *testing.T) { t.Fatalf("failed with seed %d: total: got %d, want 0.", seed, total) } - f := filters.Get(1) + f := filters.Get(firstID) if f == nil { t.Fatalf("failed to get the filter with seed %d.", seed) } |