aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5
diff options
context:
space:
mode:
authorEugene Valeyev <evgen.povt@gmail.com>2018-08-13 22:27:25 +0800
committerGuillaume Ballet <gballet@gmail.com>2018-08-13 22:27:25 +0800
commite07e507d1af687cd64b263038ebd3cb7be74fb40 (patch)
tree0b515ed937abceb3425ae4a17d72821db6b4f90e /whisper/whisperv5
parentd8328a96b4943798f9dd2a8ae1c787f7e78ff8e4 (diff)
downloadgo-tangerine-e07e507d1af687cd64b263038ebd3cb7be74fb40.tar
go-tangerine-e07e507d1af687cd64b263038ebd3cb7be74fb40.tar.gz
go-tangerine-e07e507d1af687cd64b263038ebd3cb7be74fb40.tar.bz2
go-tangerine-e07e507d1af687cd64b263038ebd3cb7be74fb40.tar.lz
go-tangerine-e07e507d1af687cd64b263038ebd3cb7be74fb40.tar.xz
go-tangerine-e07e507d1af687cd64b263038ebd3cb7be74fb40.tar.zst
go-tangerine-e07e507d1af687cd64b263038ebd3cb7be74fb40.zip
whisper: fixed broken partial topic filtering
Changes in #15811 broke partial topic filtering. Re-enable it.
Diffstat (limited to 'whisper/whisperv5')
-rw-r--r--whisper/whisperv5/filter.go2
-rw-r--r--whisper/whisperv5/filter_test.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/whisper/whisperv5/filter.go b/whisper/whisperv5/filter.go
index 3190334eb..9550a7e38 100644
--- a/whisper/whisperv5/filter.go
+++ b/whisper/whisperv5/filter.go
@@ -220,7 +220,7 @@ func matchSingleTopic(topic TopicType, bt []byte) bool {
bt = bt[:TopicLength]
}
- if len(bt) < TopicLength {
+ if len(bt) == 0 {
return false
}
diff --git a/whisper/whisperv5/filter_test.go b/whisper/whisperv5/filter_test.go
index 01034a351..c01c22668 100644
--- a/whisper/whisperv5/filter_test.go
+++ b/whisper/whisperv5/filter_test.go
@@ -829,16 +829,16 @@ func TestMatchSingleTopic_WithTail_ReturnTrue(t *testing.T) {
}
}
-func TestMatchSingleTopic_NotEquals_ReturnFalse(t *testing.T) {
+func TestMatchSingleTopic_PartialTopic_ReturnTrue(t *testing.T) {
bt := []byte("tes")
- topic := BytesToTopic(bt)
+ topic := BytesToTopic([]byte("test"))
- if matchSingleTopic(topic, bt) {
+ if !matchSingleTopic(topic, bt) {
t.FailNow()
}
}
-func TestMatchSingleTopic_InsufficientLength_ReturnFalse(t *testing.T) {
+func TestMatchSingleTopic_NotEquals_ReturnFalse(t *testing.T) {
bt := []byte("test")
topic := BytesToTopic([]byte("not_equal"))