Skip to content

Commit

Permalink
Update Other errors to HostUnreachable
Browse files Browse the repository at this point in the history
Rust 1.83 has dropped and with it comes new error kinds!
  • Loading branch information
brandonpike committed Nov 30, 2024
1 parent 49a7038 commit 4b50389
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ mod test {
sim.client("client", async move {
// Peers are partitioned. TCP setup should fail.
let err = TcpStream::connect("server:1234").await.unwrap_err();
assert_eq!(err.kind(), io::ErrorKind::Other);
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand Down
6 changes: 1 addition & 5 deletions src/top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,7 @@ impl Topology {
link.enqueue_message(&self.config, rand, src, dst, message);
Ok(())
} else {
// TODO: `ErrorKind::Other` is incorrect here, but
// `ErrorKind::HostUnreachable` has not been stabilized.
//
// See: https://github.com/rust-lang/rust/issues/86442
Err(Error::new(ErrorKind::Other, "host unreachable"))
Err(Error::new(ErrorKind::HostUnreachable, "host unreachable"))
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn network_partitions_during_connect() -> Result {
turmoil::partition("client", "server");

let err = TcpStream::connect(("server", PORT)).await.unwrap_err();
assert_eq!(err.kind(), io::ErrorKind::Other);
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

turmoil::repair("client", "server");
Expand Down Expand Up @@ -220,7 +220,7 @@ fn network_partition_once_connected() -> Result {
assert!(timeout(Duration::from_secs(1), s.read_u8()).await.is_err());

let err = s.write_u8(1).await.unwrap_err();
assert_eq!(err.kind(), io::ErrorKind::Other);
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand All @@ -232,7 +232,7 @@ fn network_partition_once_connected() -> Result {
turmoil::partition("server", "client");

let err = s.write_u8(1).await.unwrap_err();
assert_eq!(err.kind(), io::ErrorKind::Other);
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand Down Expand Up @@ -1129,7 +1129,7 @@ fn socket_to_nonexistent_node() -> Result {
);

let err = sock.unwrap_err();
assert_eq!(err.kind(), io::ErrorKind::Other);
assert_eq!(err.kind(), io::ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions tests/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn network_partition() -> Result {

let sock = bind().await?;
let err = send_ping(&sock).await.unwrap_err();
assert_eq!(err.kind(), ErrorKind::Other);
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand Down Expand Up @@ -562,7 +562,7 @@ fn loopback_localhost_public_v4() -> Result {
let bind_addr = SocketAddr::new(bind_addr.ip(), 0);
let socket = UdpSocket::bind(bind_addr).await?;
let err = socket.send_to(&expected, connect_addr).await.unwrap_err();
assert_eq!(err.kind(), ErrorKind::Other);
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand Down Expand Up @@ -614,7 +614,7 @@ fn loopback_localhost_public_v6() -> Result {
let bind_addr = SocketAddr::new(bind_addr.ip(), 0);
let socket = UdpSocket::bind(bind_addr).await?;
let err = socket.send_to(&expected, connect_addr).await.unwrap_err();
assert_eq!(err.kind(), ErrorKind::Other);
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand Down Expand Up @@ -723,7 +723,7 @@ fn socket_to_nonexistent_node() -> Result {
);

let err = send.unwrap_err();
assert_eq!(err.kind(), ErrorKind::Other);
assert_eq!(err.kind(), ErrorKind::HostUnreachable);
assert_eq!(err.to_string(), "host unreachable");

Ok(())
Expand Down

0 comments on commit 4b50389

Please sign in to comment.