diff --git a/tests/codex/blockexchange/discovery/testdiscovery.nim b/tests/codex/blockexchange/discovery/testdiscovery.nim index 0cc14837..23cc1996 100644 --- a/tests/codex/blockexchange/discovery/testdiscovery.nim +++ b/tests/codex/blockexchange/discovery/testdiscovery.nim @@ -242,8 +242,13 @@ asyncchecksuite "E2E - Multiple Nodes Discovery": .publishBlockProvideHandler = proc(d: MockDiscovery, cid: Cid): Future[void] {.async.} = advertised[cid] = switch[3].peerInfo.signedPeerRecord + discard blocks[0..5].mapIt(blockexc[1].engine.pendingBlocks.getWantHandle(it.address)) await blockexc[1].engine.blocksDeliveryHandler(switch[0].peerInfo.peerId, blocks[0..5].mapIt(BlockDelivery(blk: it, address: it.address))) + + discard blocks[4..10].mapIt(blockexc[2].engine.pendingBlocks.getWantHandle(it.address)) await blockexc[2].engine.blocksDeliveryHandler(switch[0].peerInfo.peerId, blocks[4..10].mapIt(BlockDelivery(blk: it, address: it.address))) + + discard blocks[10..15].mapIt(blockexc[3].engine.pendingBlocks.getWantHandle(it.address)) await blockexc[3].engine.blocksDeliveryHandler(switch[0].peerInfo.peerId, blocks[10..15].mapIt(BlockDelivery(blk: it, address: it.address))) MockDiscovery(blockexc[0].engine.discovery.discovery) @@ -258,13 +263,13 @@ asyncchecksuite "E2E - Multiple Nodes Discovery": await allFuturesThrowing( switch.mapIt( it.start() ) & - blockexc.mapIt( it.engine.start() )) + blockexc.mapIt( it.engine.start() )).wait(10.seconds) - await allFutures(futs) + await allFutures(futs).wait(10.seconds) await allFuturesThrowing( blockexc.mapIt( it.engine.stop() ) & - switch.mapIt( it.stop() )) + switch.mapIt( it.stop() )).wait(10.seconds) test "E2E - Should advertise and discover blocks with peers already connected": # Distribute the blocks amongst 1..3 @@ -284,8 +289,13 @@ asyncchecksuite "E2E - Multiple Nodes Discovery": .publishBlockProvideHandler = proc(d: MockDiscovery, cid: Cid): Future[void] {.async.} = advertised[cid] = switch[3].peerInfo.signedPeerRecord + discard blocks[0..5].mapIt(blockexc[1].engine.pendingBlocks.getWantHandle(it.address)) await blockexc[1].engine.blocksDeliveryHandler(switch[0].peerInfo.peerId, blocks[0..5].mapIt(BlockDelivery(blk: it, address: it.address))) + + discard blocks[4..10].mapIt(blockexc[2].engine.pendingBlocks.getWantHandle(it.address)) await blockexc[2].engine.blocksDeliveryHandler(switch[0].peerInfo.peerId, blocks[4..10].mapIt(BlockDelivery(blk: it, address: it.address))) + + discard blocks[10..15].mapIt(blockexc[3].engine.pendingBlocks.getWantHandle(it.address)) await blockexc[3].engine.blocksDeliveryHandler(switch[0].peerInfo.peerId, blocks[10..15].mapIt(BlockDelivery(blk: it, address: it.address))) MockDiscovery(blockexc[0].engine.discovery.discovery) @@ -299,10 +309,10 @@ asyncchecksuite "E2E - Multiple Nodes Discovery": await allFuturesThrowing( switch.mapIt( it.start() ) & - blockexc.mapIt( it.engine.start() )) + blockexc.mapIt( it.engine.start() )).wait(10.seconds) await allFutures(futs).wait(10.seconds) await allFuturesThrowing( blockexc.mapIt( it.engine.stop() ) & - switch.mapIt( it.stop() )) + switch.mapIt( it.stop() )).wait(10.seconds) diff --git a/tests/codex/blockexchange/engine/testblockexc.nim b/tests/codex/blockexchange/engine/testblockexc.nim index 3552a1ea..e1a8fef3 100644 --- a/tests/codex/blockexchange/engine/testblockexc.nim +++ b/tests/codex/blockexchange/engine/testblockexc.nim @@ -120,6 +120,7 @@ asyncchecksuite "NetworkStore engine - 2 nodes": test "Should send want-have for block": let blk = bt.Block.new("Block 1".toBytes).tryGet() + let blkFut = nodeCmps1.pendingBlocks.getWantHandle( blk.cid ) (await nodeCmps2.localStore.putBlock(blk)).tryGet() let entry = WantListEntry( @@ -136,6 +137,7 @@ asyncchecksuite "NetworkStore engine - 2 nodes": .pushOrUpdateNoWait(peerCtx1).isOk check eventually (await nodeCmps1.localStore.hasBlock(blk.cid)).tryGet() + check eventually (await blkFut) == blk test "Should get blocks from remote": let