From c7ffd397d1da5aeeb11df2b8e1fc0516b9bd8bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 22 May 2025 15:07:37 +0200 Subject: [PATCH] chore(test): make proxy test robust wrt IPv4/v6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this test fails if hyper.rs resolves to an IPv6 address in the test env otherwise.. Signed-off-by: Fabian Grünbichler --- tests/proxy.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/proxy.rs b/tests/proxy.rs index 86c386f..e2096ff 100644 --- a/tests/proxy.rs +++ b/tests/proxy.rs @@ -327,9 +327,10 @@ async fn test_socks_v5_with_locally_resolved_domain_works() { // command req/res let n = to_client.read(&mut buf).await.expect("read 3"); - let message = [0x05, 0x01, 0x00, 0x01]; - assert_eq!(&buf[..4], message); - assert_eq!(n, 4 + 4 + 2); + let message = [0x05, 0x01, 0x00]; + assert_eq!(&buf[..3], message); + assert!(buf[3] == 0x01 || buf[3] == 0x04); // IPv4 or IPv6 + assert_eq!(n, 4 + 4 * (buf[3] as usize) + 2); let message = vec![0x05, 0x00, 0x00, 0x01, 0, 0, 0, 0, 0, 0]; to_client.write_all(&message).await.expect("write 3");