Skip to content

Commit

Permalink
test: Test incorrect protocol identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzac committed Oct 5, 2023
1 parent dcc8287 commit d900a6c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions waku/v2/protocol/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"errors"
libp2pProtocol "github.com/libp2p/go-libp2p/core/protocol"
"net/http"
"sync"
"testing"
Expand Down Expand Up @@ -520,6 +521,40 @@ func (s *FilterTestSuite) TestAutoShard() {

}

func (s *FilterTestSuite) TestIncorrectProtoIdentifiers() {
log := utils.Logger()
s.log = log
s.wg = &sync.WaitGroup{}

// Create test context
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) // Test can't exceed 10 seconds
s.ctx = ctx
s.ctxCancel = cancel

s.testTopic = "/waku/2/go/filter/test"
s.testContentTopic = "TopicA"

s.lightNode = s.makeWakuFilterLightNode(true, true)

s.relayNode, s.fullNode = s.makeWakuFilterFullNode(s.testTopic)

const FilterSubscribeID_Incorrect1 = libp2pProtocol.ID("/vac/waku/filter-subscribe/abcd")

// Connect nodes
s.lightNodeHost.Peerstore().AddAddr(s.fullNodeHost.ID(), tests.GetHostAddress(s.fullNodeHost), peerstore.PermanentAddrTTL)
err := s.lightNodeHost.Peerstore().AddProtocols(s.fullNodeHost.ID(), FilterSubscribeID_Incorrect1)
s.Require().NoError(err)

// Subscribe
s.contentFilter = protocol.ContentFilter{PubsubTopic: s.testTopic, ContentTopics: protocol.NewContentTopicSet(s.testContentTopic)}
_, err = s.lightNode.Subscribe(s.ctx, s.contentFilter, WithPeer(s.fullNodeHost.ID()))

// Error "filter/options.go:68 selecting peer {"error": "no suitable peers found"}" is expected to bubble up ?

s.Require().Error(err)

}

func (s *FilterTestSuite) BeforeTest(suiteName, testName string) {
s.log.Info("Executing ", zap.String("testName", testName))
}
Expand Down

0 comments on commit d900a6c

Please sign in to comment.