Skip to content

Commit

Permalink
address issue with relay test code
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaprem committed Oct 20, 2023
1 parent 9b3a0b8 commit b1f1b0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions waku/v2/protocol/relay/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions waku/v2/protocol/relay/waku_relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down

0 comments on commit b1f1b0b

Please sign in to comment.