summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
diff options
context:
space:
mode:
authorJoakim Hulthe <joakim@hulthe.net>2025-06-10 17:35:07 +0200
committerJoakim Hulthe <joakim.hulthe@mullvad.net>2025-06-11 17:45:31 +0200
commit0fb88d81ec354cc18f71888dd3d4bd7cfcb582a2 (patch)
treec2d0a8e6b18cc08c9d723c044e007cd2b9d73bb3 /talpid-core/src
parentba7127bb0c1a388a0f2affea459d6943be5db71b (diff)
downloadmullvadvpn-0fb88d81ec354cc18f71888dd3d4bd7cfcb582a2.tar.xz
mullvadvpn-0fb88d81ec354cc18f71888dd3d4bd7cfcb582a2.zip
Make flakey unit test less flakey
For some reason, the UDP socket is not unbound right away when stopping the handler, so the test would sometimes fail with "Address in use"
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/resolver.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/talpid-core/src/resolver.rs b/talpid-core/src/resolver.rs
index 2a69998b2e..cbf83d65c7 100644
--- a/talpid-core/src/resolver.rs
+++ b/talpid-core/src/resolver.rs
@@ -691,7 +691,7 @@ mod test {
config::{NameServerConfigGroup, ResolverConfig, ResolverOpts},
TokioAsyncResolver,
};
- use std::{net::UdpSocket, sync::Mutex};
+ use std::{net::UdpSocket, sync::Mutex, thread};
use typed_builder::TypedBuilder;
/// Can't have multiple local resolvers running at the same time, as they will try to bind to
@@ -747,6 +747,7 @@ mod test {
.expect("lookup should succeed");
drop(_sock);
handle.stop().await;
+ thread::sleep(Duration::from_millis(300));
// bind() succeeds if wildcard address is bound with REUSEADDR and REUSEPORT
let _sock = bind_sock(
@@ -826,6 +827,7 @@ mod test {
let addr = handle.listening_addr();
assert_eq!(addr, SocketAddr::from((Ipv4Addr::LOCALHOST, DNS_PORT)));
rt.block_on(handle.stop());
+ thread::sleep(Duration::from_millis(300));
UdpSocket::bind(addr).expect("Failed to bind to a port that should have been removed");
}