Skip to content

Commit

Permalink
Requesting the same CID sometimes causes a worker to discard the requ…
Browse files Browse the repository at this point in the history
…est if it's already inflight by another worker. (#1002)
  • Loading branch information
benbierens authored Nov 27, 2024
1 parent d47ce38 commit 2124996
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/codex/blockexchange/discovery/testdiscoveryengine.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down

0 comments on commit 2124996

Please sign in to comment.