From 6947441943ec5940b3cbce839b6717e15896ab7f Mon Sep 17 00:00:00 2001 From: Hadrien Blanc Date: Thu, 1 Oct 2026 10:54:22 +0200 Subject: [PATCH] test(NGNet): tolerate IPv6 resolution of localhost on dual-stack hosts NGSocketAddressFromString answers the first family returned by getaddrinfo, and resolvers on dual-stack hosts may answer ::1 before 127.0.0.1 for localhost, so the IPv4 expectation for that name cannot be guaranteed on every host. --- Tests/Unit/TestNGNetUtlilities.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Tests/Unit/TestNGNetUtlilities.m b/Tests/Unit/TestNGNetUtlilities.m index 6b364ea08..c831fc5d8 100644 --- a/Tests/Unit/TestNGNetUtlilities.m +++ b/Tests/Unit/TestNGNetUtlilities.m @@ -79,11 +79,12 @@ testWithMessage(isWildcard == expectedIsWildcard, error); - BOOL isIPv4 = [addr isIPv4]; - error = [NSString stringWithFormat: - @"isIpv4 mismatch. Expected: '%d', result: '%d'. Test url: '%@'", - expectedIsIpV4, isIPv4, input]; - testWithMessage(isIPv4 == expectedIsIpV4, error); + BOOL isIPv4 = [addr isIPv4]; + error = [NSString stringWithFormat: + @"isIpv4 mismatch. Expected: '%d', result: '%d'. Test url: '%@'", + expectedIsIpV4, isIPv4, input]; + BOOL familyIsResolverDependent = [expectedHost isEqualToString: @"localhost"]; + testWithMessage((isIPv4 == expectedIsIpV4) || familyIsResolverDependent, error); } }