Skip to content

Commit

Permalink
Tests 4; remove broadcaster logic in MakeFilterLightNode
Browse files Browse the repository at this point in the history
  • Loading branch information
vitvly committed Mar 28, 2024
1 parent 9a3b023 commit ccf8da1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions waku/v2/protocol/filter/filter_proto_ident_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (s *FilterTestSuite) TestIncorrectSubscribeIdentifier() {
s.testTopic = defaultTestPubSubTopic
s.testContentTopic = defaultTestContentTopic

s.lightNode = s.StartNode(s.MakeWakuFilterLightNode(true))
s.lightNode = s.StartNode(s.MakeWakuFilterLightNode())

s.relayNode, s.fullNode = s.MakeWakuFilterFullNode(s.testTopic, false)

Expand Down Expand Up @@ -270,7 +270,7 @@ func (s *FilterTestSuite) TestIncorrectPushIdentifier() {
s.testTopic = defaultTestPubSubTopic
s.testContentTopic = defaultTestContentTopic

s.lightNode = s.MakeWakuFilterLightNode(true)
s.lightNode = s.MakeWakuFilterLightNode()

s.relayNode, s.fullNode = s.MakeWakuFilterFullNode(s.testTopic, false)

Expand Down
4 changes: 2 additions & 2 deletions waku/v2/protocol/filter/filter_subscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s *FilterTestSuite) TestMultiPubSubMultiContentTopic() {
// Create test context
s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 20*time.Second) // Test can't exceed 20 seconds

s.lightNode = s.StartNode(s.MakeWakuFilterLightNode(true))
s.lightNode = s.StartNode(s.MakeWakuFilterLightNode())

s.relayNode, s.fullNode = s.MakeWakuFilterFullNode(s.testTopic, true)

Expand Down Expand Up @@ -308,7 +308,7 @@ func (s *FilterTestSuite) TestSubscribeMultipleLightNodes() {
// Create test context
s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 10*time.Second) // Test can't exceed 10 seconds

lightNode2 := s.StartNode(s.MakeWakuFilterLightNode(true))
lightNode2 := s.StartNode(s.MakeWakuFilterLightNode())

// Connect node2
lightNode2.h.Peerstore().AddAddr(s.fullNodeHost.ID(), tests.GetHostAddress(s.fullNodeHost), peerstore.PermanentAddrTTL)
Expand Down
15 changes: 6 additions & 9 deletions waku/v2/protocol/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,14 @@ func (s *FilterTestSuite) MakeWakuFilterFullNode(topic string, withRegisterAll b
return relayData.WakuRelay, node2Filter
}

func (s *FilterTestSuite) MakeWakuFilterLightNode(withBroadcaster bool) *WakuFilterLightNode {
func (s *FilterTestSuite) MakeWakuFilterLightNode() *WakuFilterLightNode {
port, err := tests.FindFreePort(s.T(), "", 5)
s.Require().NoError(err)

host, err := tests.MakeHost(context.Background(), port, rand.Reader)
s.Require().NoError(err)
var b relay.Broadcaster
if withBroadcaster {
b = relay.NewBroadcaster(10)
s.Require().NoError(b.Start(context.Background()))
}
b := relay.NewBroadcaster(10)
s.Require().NoError(b.Start(context.Background()))
filterPush := NewWakuFilterLightNode(b, nil, timesource.NewDefaultClock(), prometheus.DefaultRegisterer, s.Log)
filterPush.SetHost(host)
s.lightNodeHost = host
Expand Down Expand Up @@ -372,7 +369,7 @@ func (s *FilterTestSuite) SetupTest() {
s.testTopic = defaultTestPubSubTopic
s.testContentTopic = defaultTestContentTopic

s.lightNode = s.StartNode(s.MakeWakuFilterLightNode(true))
s.lightNode = s.StartNode(s.MakeWakuFilterLightNode())

//TODO: Add tests to verify broadcaster.

Expand Down Expand Up @@ -435,7 +432,7 @@ func (s *FilterTestSuite) TestStartStop() {

var wg sync.WaitGroup
wg.Add(2)
s.lightNode = s.MakeWakuFilterLightNode(false)
s.lightNode = s.MakeWakuFilterLightNode()

stopNode := func() {
for i := 0; i < 100000; i++ {
Expand Down Expand Up @@ -479,7 +476,7 @@ func (s *FilterTestSuite) TestAutoShard() {
s.testContentTopic = cTopic1Str
s.testTopic = pubSubTopic.String()

s.lightNode = s.StartNode(s.MakeWakuFilterLightNode(false))
s.lightNode = s.StartNode(s.MakeWakuFilterLightNode())
s.relayNode, s.fullNode = s.MakeWakuFilterFullNode(pubSubTopic.String(), false)

s.lightNodeHost.Peerstore().AddAddr(s.fullNodeHost.ID(), tests.GetHostAddress(s.fullNodeHost), peerstore.PermanentAddrTTL)
Expand Down
6 changes: 3 additions & 3 deletions waku/v2/protocol/filter/filter_unsubscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (s *FilterTestSuite) TestUnsubscribeMultiPubSubMultiContentTopic() {

s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 20*time.Second)

s.lightNode = s.StartNode(s.MakeWakuFilterLightNode(true))
s.lightNode = s.StartNode(s.MakeWakuFilterLightNode())

s.relayNode, s.fullNode = s.MakeWakuFilterFullNode(s.testTopic, true)

Expand Down Expand Up @@ -128,7 +128,7 @@ func (s *FilterTestSuite) TestUnsubscribeErrorHandling() {

s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 20*time.Second)

s.lightNode = s.StartNode(s.MakeWakuFilterLightNode(true))
s.lightNode = s.StartNode(s.MakeWakuFilterLightNode())

s.relayNode, s.fullNode = s.MakeWakuFilterFullNode(s.testTopic, true)

Expand Down Expand Up @@ -229,7 +229,7 @@ func (s *FilterTestSuite) TestUnsubscribeAllDiffPubSubContentTopics() {

s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 20*time.Second)

s.lightNode = s.StartNode(s.MakeWakuFilterLightNode(true))
s.lightNode = s.StartNode(s.MakeWakuFilterLightNode())

s.relayNode, s.fullNode = s.MakeWakuFilterFullNode(s.testTopic, true)

Expand Down

0 comments on commit ccf8da1

Please sign in to comment.