mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
whisper: fixed broken partial topic filtering
This commit is contained in:
parent
933972d139
commit
d7808c8ffb
4 changed files with 8 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue