aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/libp2p/tests.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 05:00:43 +0100
committertv <tv@krebsco.de>2026-11-01 05:00:43 +0100
commitab6a83c5c666dfc8603f0eae1537c30f7ee61ee1 (patch)
tree4ee986476c22c24b07b19b0f55601917df2b89da /src/transport/libp2p/tests.rs
parenta2fb105ad94198bd342aa4586b742439e1a60083 (diff)
libp2p: dial newly announced peer addresses
Diffstat (limited to 'src/transport/libp2p/tests.rs')
-rw-r--r--src/transport/libp2p/tests.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/transport/libp2p/tests.rs b/src/transport/libp2p/tests.rs
index 3d11913..ed23b34 100644
--- a/src/transport/libp2p/tests.rs
+++ b/src/transport/libp2p/tests.rs
@@ -696,6 +696,35 @@ fn ignored_addresses_not_kept() {
assert!(!book.knows(them, &[via_vpn]));
}
+/// A node connected directly over the WLAN dials the ethernet address it later hears
+/// of, once; and when an interface of ours comes, every address again, the one in use
+/// too.
+#[test]
+fn better_paths_explored() {
+ let mut book = Book::default();
+ let them = peer();
+ let wlan: Multiaddr = "/ip4/192.168.1.7/tcp/9661".parse().unwrap();
+ let ethernet: Multiaddr = "/ip4/192.168.2.7/tcp/9661".parse().unwrap();
+ book.continuum.insert(them);
+ book.remember(them, wlan.clone());
+ // Connected (inbound: from another port) over the WLAN.
+ book.connections.insert(
+ ConnectionId::new_unchecked(1),
+ (them, false, "/ip4/192.168.1.7/tcp/40000".parse().unwrap()),
+ );
+ assert!(book.to_explore(them, false).is_empty());
+ book.identified(them, vec![wlan.clone(), ethernet.clone()]);
+ assert_eq!(book.to_explore(them, false), [ethernet.clone()]);
+ assert!(book.to_explore(them, false).is_empty());
+ // An interface of ours came (`driver`): all of them again.
+ book.explored.clear();
+ let mut again = book.to_explore(them, true);
+ again.sort();
+ let mut both = vec![wlan, ethernet];
+ both.sort();
+ assert_eq!(again, both);
+}
+
/// Peers nobody mentions any more are forgotten, but connected ones.
#[test]
fn stale_peers_are_forgotten() {