Skip to content

Commit

Permalink
Fix race bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Vlasov committed Sep 22, 2023
1 parent d6fed8e commit 391b05b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions waku/v2/protocol/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ func (s *FilterTestSuite) waitForMsg(fn func(), ch chan *protocol.Envelope) {
}
}()

fn()
if fn != nil {
fn()
}

s.wg.Wait()
}
Expand All @@ -134,7 +136,7 @@ func (s *FilterTestSuite) waitForTimeout(fn func(), ch chan *protocol.Envelope)
case <-time.After(1 * time.Second):
// Timeout elapsed, all good
case <-s.ctx.Done():
s.Require().Fail("test exceeded allocated time")
s.Require().Fail("waitForTimeout test exceeded allocated time")
}
}()

Expand Down Expand Up @@ -241,6 +243,9 @@ func (s *FilterTestSuite) TestWakuFilter() {
s.publishMsg(s.testTopic, s.testContentTopic, "fifth")
}, secondSub[0].C)

s.waitForMsg(nil, s.subDetails[0].C)
s.waitForMsg(nil, secondSub[0].C)

// Unsubscribe from second sub only
_, err = s.lightNode.UnsubscribeWithSubscription(s.ctx, secondSub[0])
s.Require().NoError(err)
Expand Down

0 comments on commit 391b05b

Please sign in to comment.