From f0eedf453e4399507609cd3d3d55cfd0585788dc Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:28:45 -0700 Subject: [PATCH] paths: a local client's announced path is responsive --- crates/rns-transport/src/actor/inbound.rs | 4 ++ .../actor/tests/local_client_path_response.rs | 49 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/crates/rns-transport/src/actor/inbound.rs b/crates/rns-transport/src/actor/inbound.rs index 3cfc764..bf5ce88 100644 --- a/crates/rns-transport/src/actor/inbound.rs +++ b/crates/rns-transport/src/actor/inbound.rs @@ -1118,6 +1118,10 @@ impl TransportActor { tunnel.expires = now_f64() + TUNNEL_TIMEOUT as f64; } } + // Transport.py: a local client's announce or path response proves it live. + if is_from_local_client { + self.mark_path_responsive(&header.destination_hash); + } self.state_dirty = true; if self.path_requests.contains_key(&header.destination_hash) { self.use_destination(&header.destination_hash); diff --git a/crates/rns-transport/src/actor/tests/local_client_path_response.rs b/crates/rns-transport/src/actor/tests/local_client_path_response.rs index 4a25cb0..e042a39 100644 --- a/crates/rns-transport/src/actor/tests/local_client_path_response.rs +++ b/crates/rns-transport/src/actor/tests/local_client_path_response.rs @@ -116,3 +116,52 @@ async fn local_client_path_response_is_rebroadcast_once_everywhere() { tx.send(TransportMessage::Shutdown).await.unwrap(); running.await.unwrap(); } + +fn inbound(actor: &mut TransportActor, raw: Bytes, interface_id: InterfaceId) { + actor.on_inbound(InboundPacket { + raw, + interface_id, + rssi: None, + snr: None, + q: None, + }); +} + +/// Transport.py 1.6.1 (833f6cf2): a local client's announce leaves its path +/// responsive and used, also when the rate limit holds it back; another +/// announce leaves the path unknown and unused. +#[test] +fn local_client_announce_marks_its_path_responsive() { + let (mut actor, _tx) = TransportActor::new(); + let (external, _external_rx) = make_test_interface("external"); + let (mut client, _client_rx) = make_test_interface("local-client"); + client.role = InterfaceRole::LocalClient; + client = client.with_announce_rate(3600.0, 0, 0.0); + actor.interfaces.insert(1, external); + actor.interfaces.insert(2, client); + + let (remote, remote_dest) = make_valid_announce("t16.remote", 0); + inbound(&mut actor, remote, 1); + assert_eq!(actor.path_table.get_state(&remote_dest), PathState::Unknown); + assert_eq!(actor.path_table.get(&remote_dest).unwrap().used, 0.0); + + let identity = rns_identity::identity::Identity::new(); + let mut queued = None; + for emitted in [1_000, 2_000] { + let (raw, dest) = + make_announce_for_with_random_blob(&identity, "t16.local", 0, random_blob(1, emitted)); + inbound(&mut actor, raw, 2); + // The second is rate-blocked: its rebroadcast is not queued. + let entry = actor.announce_table.get(&dest).unwrap().packet_raw.clone(); + assert_eq!(*queued.get_or_insert_with(|| entry.clone()), entry); + let path = actor.path_table.get(&dest).unwrap(); + assert!(path.has_random_blob(&random_blob(1, emitted))); + assert_eq!(path.hops, 0); + assert!(path.used > 0.0, "emitted {emitted}"); + assert_eq!( + actor.path_table.get_state(&dest), + PathState::Responsive, + "emitted {emitted}" + ); + } +}