Skip to content

Commit

Permalink
fixup: test within-range port
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Jul 31, 2024
1 parent d7698d5 commit bbc96e8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mullvad-relay-selector/src/relay_selector/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,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();

Expand All @@ -233,6 +234,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,
Expand Down

0 comments on commit bbc96e8

Please sign in to comment.