Skip to content

Commit

Permalink
fix(tests): fix flaky test (#1972)
Browse files Browse the repository at this point in the history
  • Loading branch information
alrevuelta authored Aug 31, 2023
1 parent d262837 commit f262397
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/waku_rln_relay/test_wakunode_rln_relay.nim
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,28 @@ procSuite "WakuNode - RLN relay":
nodes[2].subscribe(pubsubTopics[1], relayHandler)
await sleepAsync(1000.millis)

# publish 3 messages from node[0] (last 2 are spam, window is 10 secs)
# generate some messages with rln proofs first. generating
# the proof takes some time, so this is done before publishing
# to avoid blocking the test
var messages1: seq[WakuMessage] = @[]
var messages2: seq[WakuMessage] = @[]

let epochTime = epochTime()

for i in 0..<3:
var message1 = WakuMessage(payload: ("Payload_" & $i).toBytes(), contentTopic: contentTopics[0])
doAssert(nodes[0].wakuRlnRelay.appendRLNProof(message1, epochTime()))
await nodes[0].publish(pubsubTopics[0], message1)
var message = WakuMessage(payload: ("Payload_" & $i).toBytes(), contentTopic: contentTopics[0])
doAssert(nodes[0].wakuRlnRelay.appendRLNProof(message, epochTime))
messages1.add(message)

# publish 3 messages from node[1] (last 2 are spam, window is 10 secs)
for i in 0..<3:
var message2 = WakuMessage(payload: ("Payload_" & $i).toBytes(), contentTopic: contentTopics[1])
doAssert(nodes[1].wakuRlnRelay.appendRLNProof(message2, epochTime()))
await nodes[1].publish(pubsubTopics[1], message2)
var message = WakuMessage(payload: ("Payload_" & $i).toBytes(), contentTopic: contentTopics[1])
doAssert(nodes[1].wakuRlnRelay.appendRLNProof(message, epochTime))
messages2.add(message)

# publish 3 messages from node[0] (last 2 are spam, window is 10 secs)
# publish 3 messages from node[1] (last 2 are spam, window is 10 secs)
for msg in messages1: await nodes[0].publish(pubsubTopics[0], msg)
for msg in messages2: await nodes[1].publish(pubsubTopics[1], msg)

# wait for gossip to propagate
await sleepAsync(5000.millis)
Expand Down

0 comments on commit f262397

Please sign in to comment.