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
This commit is contained in:
Daniel Norman 2026-06-19 21:57:43 +02:00 committed by Fintan Halpenny
parent 3459ad57cc
commit d973a548b9
1 changed files with 17 additions and 0 deletions

View File

@ -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]"
);
}
}