From 09ccd3f098cf40bf43f09e70e01d47a3f7d004d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Mon, 29 Jul 2024 15:29:29 +0200 Subject: [PATCH] fixup: test within-range port --- .../src/relay_selector/helpers.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mullvad-relay-selector/src/relay_selector/helpers.rs b/mullvad-relay-selector/src/relay_selector/helpers.rs index 2f1418daf1c7..962c0398e72d 100644 --- a/mullvad-relay-selector/src/relay_selector/helpers.rs +++ b/mullvad-relay-selector/src/relay_selector/helpers.rs @@ -221,6 +221,7 @@ mod tests { #[test] fn test_shadowsocks_no_extra_addrs() { const PORT_RANGES: &[(u16, u16)] = &[(100, 200), (1000, 2000)]; + const WITHIN_RANGE_PORT: u16 = 100; const OUT_OF_RANGE_PORT: u16 = 1; let wg_in_ip: IpAddr = "1.2.3.4".parse().unwrap(); @@ -234,6 +235,20 @@ mod tests { "expected port in port range" ); + let selected_addr = get_shadowsocks_obfuscator_inner( + wg_in_ip, + PORT_RANGES, + &[], + Constraint::Only(WITHIN_RANGE_PORT), + ) + .expect("should find within-range port"); + + assert_eq!(selected_addr.ip(), wg_in_ip); + assert!( + port_in_range(selected_addr.port(), PORT_RANGES), + "expected port in port range" + ); + let selected_addr = get_shadowsocks_obfuscator_inner( wg_in_ip, PORT_RANGES,