From d973a548b976f16663d3535ef5187fbbcfaf81d8 Mon Sep 17 00:00:00 2001 From: Daniel Norman Date: Fri, 19 Jun 2026 21:57:43 +0200 Subject: [PATCH] node/wire: Test connected node removes active fetch - Assert that with the peer still `Connected`, `worker_result` clears `active[rid]` as expected - Confirm the disconnect test is exercising the discard path rather than passing vacuously --- crates/radicle-node/src/wire.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/radicle-node/src/wire.rs b/crates/radicle-node/src/wire.rs index df144405..72884a0d 100644 --- a/crates/radicle-node/src/wire.rs +++ b/crates/radicle-node/src/wire.rs @@ -1498,4 +1498,21 @@ mod test { ); } + // Contrast: with the peer still `Connected`, the active entry clears too, + // confirming the test above exercises the disconnect path, not a vacuous + // assertion. + #[test] + fn worker_result_clears_active_when_peer_connected() { + let (mut wire, rid, bob_id, addr) = wire_with_active_fetch(); + + wire.peers + .insert(Token(1), Peer::connected(bob_id, addr, Link::Outbound)); + + wire.worker_result(timed_out_fetch_result(rid, bob_id)); + + assert!( + !wire.service.fetcher().active_fetches().contains_key(&rid), + "fetch result should have cleared active[rid]" + ); + } }