From 21249968d4d41d93125e6c8f276b11a5c3547923 Mon Sep 17 00:00:00 2001 From: Ben Bierens <39762930+benbierens@users.noreply.github.com> Date: Wed, 27 Nov 2024 08:13:34 +0100 Subject: [PATCH] Requesting the same CID sometimes causes a worker to discard the request if it's already inflight by another worker. (#1002) --- .../blockexchange/discovery/testdiscoveryengine.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/codex/blockexchange/discovery/testdiscoveryengine.nim b/tests/codex/blockexchange/discovery/testdiscoveryengine.nim index 61a6f09f..17ada6ad 100644 --- a/tests/codex/blockexchange/discovery/testdiscoveryengine.nim +++ b/tests/codex/blockexchange/discovery/testdiscoveryengine.nim @@ -111,10 +111,11 @@ asyncchecksuite "Test Discovery Engine": minPeersPerBlock = minPeers) want = newAsyncEvent() + var pendingCids = newSeq[Cid]() blockDiscovery.findBlockProvidersHandler = proc(d: MockDiscovery, cid: Cid): Future[seq[SignedPeerRecord]] {.async, gcsafe.} = - - check cid == blocks[0].cid + check cid in pendingCids + pendingCids.keepItIf(it != cid) check peerStore.len < minPeers var peerCtx = BlockExcPeerCtx(id: PeerId.example) @@ -126,8 +127,12 @@ asyncchecksuite "Test Discovery Engine": want.fire() await discoveryEngine.start() + var idx = 0 while peerStore.len < minPeers: - discoveryEngine.queueFindBlocksReq(@[blocks[0].cid]) + let cid = blocks[idx].cid + inc idx + pendingCids.add(cid) + discoveryEngine.queueFindBlocksReq(@[cid]) await want.wait() want.clear()