mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-08 08:23:07 +00:00
fix: fix testdiscovery so it works with stricter block protocol
This commit is contained in:
parent
544ec123c7
commit
908d527dc9
@ -561,7 +561,10 @@ proc validateBlockDelivery(self: BlockExcEngine, bd: BlockDelivery): ?!void =
|
|||||||
return success()
|
return success()
|
||||||
|
|
||||||
proc blocksDeliveryHandler*(
|
proc blocksDeliveryHandler*(
|
||||||
self: BlockExcEngine, peer: PeerId, blocksDelivery: seq[BlockDelivery]
|
self: BlockExcEngine,
|
||||||
|
peer: PeerId,
|
||||||
|
blocksDelivery: seq[BlockDelivery],
|
||||||
|
allowSpurious: bool = false,
|
||||||
) {.async: (raises: []).} =
|
) {.async: (raises: []).} =
|
||||||
trace "Received blocks from peer", peer, blocks = (blocksDelivery.mapIt(it.address))
|
trace "Received blocks from peer", peer, blocks = (blocksDelivery.mapIt(it.address))
|
||||||
|
|
||||||
@ -575,7 +578,7 @@ proc blocksDeliveryHandler*(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Unknown peers and unrequested blocks are dropped with a warning.
|
# Unknown peers and unrequested blocks are dropped with a warning.
|
||||||
if peerCtx == nil or not peerCtx.blockReceived(bd.address):
|
if not allowSpurious and (peerCtx == nil or not peerCtx.blockReceived(bd.address)):
|
||||||
warn "Dropping unrequested or duplicate block received from peer"
|
warn "Dropping unrequested or duplicate block received from peer"
|
||||||
codex_block_exchange_spurious_blocks_received.inc()
|
codex_block_exchange_spurious_blocks_received.inc()
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -216,7 +216,6 @@ asyncchecksuite "E2E - Multiple Nodes Discovery":
|
|||||||
test "E2E - Should advertise and discover blocks":
|
test "E2E - Should advertise and discover blocks":
|
||||||
# Distribute the manifests and trees amongst 1..3
|
# Distribute the manifests and trees amongst 1..3
|
||||||
# Ask 0 to download everything without connecting him beforehand
|
# Ask 0 to download everything without connecting him beforehand
|
||||||
|
|
||||||
var advertised: Table[Cid, SignedPeerRecord]
|
var advertised: Table[Cid, SignedPeerRecord]
|
||||||
|
|
||||||
MockDiscovery(blockexc[1].engine.discovery.discovery).publishBlockProvideHandler = proc(
|
MockDiscovery(blockexc[1].engine.discovery.discovery).publishBlockProvideHandler = proc(
|
||||||
@ -242,6 +241,7 @@ asyncchecksuite "E2E - Multiple Nodes Discovery":
|
|||||||
blk: mBlocks[0], address: BlockAddress(leaf: false, cid: mBlocks[0].cid)
|
blk: mBlocks[0], address: BlockAddress(leaf: false, cid: mBlocks[0].cid)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
allowSpurious = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
discard blockexc[2].engine.pendingBlocks.getWantHandle(mBlocks[1].cid)
|
discard blockexc[2].engine.pendingBlocks.getWantHandle(mBlocks[1].cid)
|
||||||
@ -252,6 +252,7 @@ asyncchecksuite "E2E - Multiple Nodes Discovery":
|
|||||||
blk: mBlocks[1], address: BlockAddress(leaf: false, cid: mBlocks[1].cid)
|
blk: mBlocks[1], address: BlockAddress(leaf: false, cid: mBlocks[1].cid)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
allowSpurious = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
discard blockexc[3].engine.pendingBlocks.getWantHandle(mBlocks[2].cid)
|
discard blockexc[3].engine.pendingBlocks.getWantHandle(mBlocks[2].cid)
|
||||||
@ -262,6 +263,7 @@ asyncchecksuite "E2E - Multiple Nodes Discovery":
|
|||||||
blk: mBlocks[2], address: BlockAddress(leaf: false, cid: mBlocks[2].cid)
|
blk: mBlocks[2], address: BlockAddress(leaf: false, cid: mBlocks[2].cid)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
allowSpurious = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
MockDiscovery(blockexc[0].engine.discovery.discovery).findBlockProvidersHandler = proc(
|
MockDiscovery(blockexc[0].engine.discovery.discovery).findBlockProvidersHandler = proc(
|
||||||
@ -311,6 +313,7 @@ asyncchecksuite "E2E - Multiple Nodes Discovery":
|
|||||||
blk: mBlocks[0], address: BlockAddress(leaf: false, cid: mBlocks[0].cid)
|
blk: mBlocks[0], address: BlockAddress(leaf: false, cid: mBlocks[0].cid)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
allowSpurious = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
discard blockexc[2].engine.pendingBlocks.getWantHandle(mBlocks[1].cid)
|
discard blockexc[2].engine.pendingBlocks.getWantHandle(mBlocks[1].cid)
|
||||||
@ -321,6 +324,7 @@ asyncchecksuite "E2E - Multiple Nodes Discovery":
|
|||||||
blk: mBlocks[1], address: BlockAddress(leaf: false, cid: mBlocks[1].cid)
|
blk: mBlocks[1], address: BlockAddress(leaf: false, cid: mBlocks[1].cid)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
allowSpurious = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
discard blockexc[3].engine.pendingBlocks.getWantHandle(mBlocks[2].cid)
|
discard blockexc[3].engine.pendingBlocks.getWantHandle(mBlocks[2].cid)
|
||||||
@ -331,6 +335,7 @@ asyncchecksuite "E2E - Multiple Nodes Discovery":
|
|||||||
blk: mBlocks[2], address: BlockAddress(leaf: false, cid: mBlocks[2].cid)
|
blk: mBlocks[2], address: BlockAddress(leaf: false, cid: mBlocks[2].cid)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
allowSpurious = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
MockDiscovery(blockexc[0].engine.discovery.discovery).findBlockProvidersHandler = proc(
|
MockDiscovery(blockexc[0].engine.discovery.discovery).findBlockProvidersHandler = proc(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user