aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/filter_test.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-02-23 16:41:47 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2017-02-23 16:41:47 +0800
commit29fac7de448c85049a97cbec3dc0819122bd2cb0 (patch)
treeeaa56d55f2ff5c15fca84a6d408d6aaff7d78404 /whisper/whisperv5/filter_test.go
parent555273495b413069e9422b04aa46251146c752b2 (diff)
downloaddexon-29fac7de448c85049a97cbec3dc0819122bd2cb0.tar
dexon-29fac7de448c85049a97cbec3dc0819122bd2cb0.tar.gz
dexon-29fac7de448c85049a97cbec3dc0819122bd2cb0.tar.bz2
dexon-29fac7de448c85049a97cbec3dc0819122bd2cb0.tar.lz
dexon-29fac7de448c85049a97cbec3dc0819122bd2cb0.tar.xz
dexon-29fac7de448c85049a97cbec3dc0819122bd2cb0.tar.zst
dexon-29fac7de448c85049a97cbec3dc0819122bd2cb0.zip
Whisper API fixed (#3687)
* whisper: wnode updated for tests with geth * whisper: updated processing of incoming messages * whisper: symmetric encryption updated * whisper: filter id type changed to enhance security * whisper: allow filter without topic for asymmetric encryption * whisper: POW updated * whisper: logging updated * whisper: spellchecker update * whisper: error handling changed * whisper: JSON field names fixed
Diffstat (limited to 'whisper/whisperv5/filter_test.go')
-rw-r--r--whisper/whisperv5/filter_test.go37
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)
}