Probe localhost at the IPv4 loopback in the discovery test

discover::tests::without_records_the_gateway_itself_is_asked starts a server on
127.0.0.1 and has the discovery ask the gateway at "127.0.0.1",
"127.0.0.1:9987" and "localhost". The probe connected to the name through the
system's resolver, and on a machine that resolves localhost to ::1 only (this
one) nothing listens there: the third address found no gateway.

The test helper that makes the probe, probing, connects to localhost at
127.0.0.1 instead. What the test checks is that the gateway is asked at the
name localhost, not what the resolver makes of it, so it no longer depends on
the resolver.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-24 14:29:29 +03:00
1 parent 4be37e1fd1
commit e614a1c3f1
1 file changed
+7 -2
+7 -2
View File
@@ -453,10 +453,15 @@ mod tests {
lookups
}
/// `lookups` asking the real `/.well-known/tsgw` at `port`.
/// `lookups` asking the real `/.well-known/tsgw` at `port`. A name is
/// connected to through the system's resolver, except `localhost`: the
/// servers of the tests listen on 127.0.0.1, and some machines resolve
/// `localhost` to `::1` only. (The test cares that the gateway is asked at
/// the name `localhost`, not what the resolver makes of it.)
fn probing(mut lookups: Lookups, port: u16) -> Lookups {
lookups.probe = Arc::new(move |name| {
async move { timeout(PROBE_TIMEOUT, well_known(&name, port)).await.ok()?.ok() }.boxed()
let host = if name == "localhost" { "127.0.0.1".to_owned() } else { name };
async move { timeout(PROBE_TIMEOUT, well_known(&host, port)).await.ok()?.ok() }.boxed()
});
lookups
}