From ca26d44db7c85167a1a37ab3d2dd43cd6d3dcea7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 11 Jan 2019 12:16:48 +1100 Subject: [PATCH] Change the IP address in the `connect_timeout_unroutable` test. Because the current address is reachable on some machines, which causes the test to fail. Fixes #44698, #50065. --- src/libstd/net/tcp.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index b75591e53fc72..d22c40bb37d4b 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -1675,9 +1675,13 @@ mod tests { #[test] fn connect_timeout_unroutable() { - // this IP is unroutable, so connections should always time out, - // provided the network is reachable to begin with. - let addr = "10.255.255.1:80".parse().unwrap(); + // We want an IP address that is always unreachable and will trigger a + // timeout, regardless of whether a network connection is available or + // not. IPv4 doesn't have any address that is guaranteed to be + // unreachable, but 192.0.2.0 is part of the TEST-NET-1 address block, + // which is reserved for documentation and examples, and so is very + // likely to be unreachable. + let addr = "192.0.2.0:80".parse().unwrap(); let e = TcpStream::connect_timeout(&addr, Duration::from_millis(250)).unwrap_err(); assert!(e.kind() == io::ErrorKind::TimedOut || e.kind() == io::ErrorKind::Other,