chore: flaky rln test (#3173)

This commit is contained in:
Darshan K 2024-11-26 13:03:23 +05:30 committed by GitHub
parent 38fcf35cdb
commit bebd3dd62c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -478,7 +478,7 @@ procSuite "WakuNode - RLN relay":
await node2.stop()
await node3.stop()
xasyncTest "clearNullifierLog: should clear epochs > MaxEpochGap":
asyncTest "clearNullifierLog: should clear epochs > MaxEpochGap":
# Given two nodes
let
contentTopic = ContentTopic("/waku/2/default-content/proto")
@ -489,6 +489,14 @@ procSuite "WakuNode - RLN relay":
node2 = newTestWakuNode(nodeKey2, parseIpAddress("0.0.0.0"), Port(0))
epochSizeSec: uint64 = 5 # This means rlnMaxEpochGap = 4
# Helper function
proc waitForNullifierLog(node: WakuNode, expectedLen: int): Future[bool] {.async.} =
for i in 0 .. 10: # Try for up to 5 seconds (10 * 500ms)
if node.wakuRlnRelay.nullifierLog.len() == expectedLen:
return true
await sleepAsync(500.millis)
return false
# Given both nodes mount relay and rlnrelay
await node1.mountRelay(shardSeq)
let wakuRlnConfig1 = buildWakuRlnConfig(1, epochSizeSec, "wakunode_10")
@ -591,7 +599,7 @@ procSuite "WakuNode - RLN relay":
await sleepAsync(publishSleepDuration)
check:
node1.wakuRlnRelay.nullifierLog.len() == 0
node2.wakuRlnRelay.nullifierLog.len() == 4
await waitForNullifierLog(node2, 4)
# Then the node 2 should have cleared the nullifier log for epochs > MaxEpochGap
# Therefore, with 4 max epochs, the first 4 messages will be published (except wm2, which shares epoch with wm1)