From 1cc44558a96ec7a9c777d1d136417b0cfcfa5a9f Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 5 Apr 2026 22:42:28 +0300 Subject: [PATCH] tests: remove explicit port random assignments --- tests/mdns_test.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/mdns_test.rs b/tests/mdns_test.rs index 2b05607..f6087bf 100644 --- a/tests/mdns_test.rs +++ b/tests/mdns_test.rs @@ -1179,9 +1179,6 @@ fn is_apple_p2p_by_name(name: &str) -> bool { } fn my_ip_interfaces() -> Vec { - // Use a random port for binding test. - let test_port = fastrand::u16(8000u16..9000u16); - if_addrs::get_if_addrs() .unwrap_or_default() .into_iter() @@ -1193,7 +1190,7 @@ fn my_ip_interfaces() -> Vec { IfAddr::V4(ifv4) => // Use a 'bind' to check if this is a valid IPv4 addr. { - match std::net::UdpSocket::bind((ifv4.ip, test_port)) { + match std::net::UdpSocket::bind((ifv4.ip, 0)) { Ok(_) => Some(i), Err(e) => { println!("failed to bind {}: {e}, skipped.", ifv4.ip); @@ -1204,7 +1201,7 @@ fn my_ip_interfaces() -> Vec { IfAddr::V6(ifv6) => // Use a 'bind' to check if this is a valid IPv6 addr. { - let mut sock = std::net::SocketAddrV6::new(ifv6.ip, test_port, 0, 0); + let mut sock = std::net::SocketAddrV6::new(ifv6.ip, 0, 0, 0); if i.is_link_local() { // Only link local IPv6 address requires to specify scope_id sock.set_scope_id(i.index.unwrap_or(0));