whisper: fixed broken partial topic filtering

This commit is contained in:
Eugene Valeyev 2018-03-23 10:27:55 +03:00
parent 933972d139
commit d7808c8ffb
4 changed files with 8 additions and 16 deletions

View file

@ -220,10 +220,6 @@ func matchSingleTopic(topic TopicType, bt []byte) bool {
bt = bt[:TopicLength]
}
if len(bt) < TopicLength {
return false
}
for j, b := range bt {
if topic[j] != b {
return false

View file

@ -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"))

View file

@ -255,10 +255,6 @@ func matchSingleTopic(topic TopicType, bt []byte) bool {
bt = bt[:TopicLength]
}
if len(bt) < TopicLength {
return false
}
for j, b := range bt {
if topic[j] != b {
return false

View file

@ -848,16 +848,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"))