From 7de94c5c2c64d9a0f69e5b9ec83a87228c1d204a Mon Sep 17 00:00:00 2001 From: Darshan K <35736874+darshankabariya@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:03:23 +0530 Subject: [PATCH] chore: flaky rln test (#3173) --- tests/waku_rln_relay/test_wakunode_rln_relay.nim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/waku_rln_relay/test_wakunode_rln_relay.nim b/tests/waku_rln_relay/test_wakunode_rln_relay.nim index aa5252454..4d07d1228 100644 --- a/tests/waku_rln_relay/test_wakunode_rln_relay.nim +++ b/tests/waku_rln_relay/test_wakunode_rln_relay.nim @@ -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)