diff --git a/waku/v2/protocol/relay/subscription.go b/waku/v2/protocol/relay/subscription.go index b901d0fbd..a7bb6a362 100644 --- a/waku/v2/protocol/relay/subscription.go +++ b/waku/v2/protocol/relay/subscription.go @@ -29,8 +29,8 @@ func (s *Subscription) Submit(ctx context.Context, msg *protocol.Envelope) { //Filter and notify // - if contentFilter doesn't have a contentTopic // - if contentFilter has contentTopics and it matches with message - if !s.noConsume && len(s.contentFilter.ContentTopicsList()) == 0 || (len(s.contentFilter.ContentTopicsList()) > 0 && - slices.Contains[string](s.contentFilter.ContentTopicsList(), msg.Message().ContentTopic)) { + if !s.noConsume && (len(s.contentFilter.ContentTopicsList()) == 0 || + (len(s.contentFilter.ContentTopicsList()) > 0 && slices.Contains[string](s.contentFilter.ContentTopicsList(), msg.Message().ContentTopic))) { select { case <-ctx.Done(): return diff --git a/waku/v2/protocol/relay/waku_relay_test.go b/waku/v2/protocol/relay/waku_relay_test.go index 99f6577d1..e49db217f 100644 --- a/waku/v2/protocol/relay/waku_relay_test.go +++ b/waku/v2/protocol/relay/waku_relay_test.go @@ -276,9 +276,8 @@ func TestWakuRelayAutoShard(t *testing.T) { _, err = relay.PublishToTopic(context.Background(), msg1, subs[0].contentFilter.PubsubTopic) require.NoError(t, err) - /* TODO: Debug why message is not received in this case. wg = waitForMsg(t, subs1[0].Ch, testcTopic1) - wg.Wait() */ + wg.Wait() //Should not receive message as subscription is for a different cTopic. waitForTimeout(t, subs[0].Ch) @@ -292,10 +291,16 @@ func TestWakuRelayAutoShard(t *testing.T) { topics = relay.Topics() require.Equal(t, 1, len(topics)) require.Equal(t, subs[0].contentFilter.PubsubTopic, topics[0]) - wg2 := waitForMsg(t, subs1[0].Ch, testcTopic1) - _, err = relay.PublishToTopic(context.Background(), msg1, subs[0].contentFilter.PubsubTopic) + msg2 := &pb.WakuMessage{ + Payload: bytesToSend, + Version: 0, + ContentTopic: testcTopic1, + Timestamp: 1, + } + + _, err = relay.PublishToTopic(context.Background(), msg2, subs[0].contentFilter.PubsubTopic) require.NoError(t, err) wg2.Wait()