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.
This commit is contained in:
Hadrien Blanc authored and QHivert committed 2026-10-07 11:16:56 +02:00
1 parent 20779cf353
commit 6947441943
1 file changed
+6 -5
+6 -5
View File
@@ -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);
}
}