From 3c36862f4213c977181cc80100381a63a205130b Mon Sep 17 00:00:00 2001 From: Marli Frost Date: Fri, 27 Mar 2020 10:09:21 +0000 Subject: [PATCH] fix: connect to LOCALHOST address in tests Windows doesn't allow us to connect to the Any (0.0.0.0) address, instead returning the WSAEADDRNOTAVAIL error code. https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2 --- common/src/net/post2.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/net/post2.rs b/common/src/net/post2.rs index ee9e7303e5..95307ac4bd 100644 --- a/common/src/net/post2.rs +++ b/common/src/net/post2.rs @@ -332,7 +332,8 @@ mod tests { #[test] fn connect() { - let (mut postoffice, sock) = create_postoffice::<(), ()>(0).unwrap(); + let (mut postoffice, bound) = create_postoffice::<(), ()>(0).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let _client0 = PostBox::<(), ()>::to(sock).unwrap(); let _client1 = PostBox::<(), ()>::to(sock).unwrap(); @@ -364,7 +365,8 @@ mod tests { #[test] fn send_recv() { - let (mut postoffice, sock) = create_postoffice::<(), i32>(2).unwrap(); + let (mut postoffice, bound) = create_postoffice::<(), i32>(2).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let test_msgs = vec![1, 1337, 42, -48]; let mut client = PostBox::::to(sock).unwrap(); @@ -386,7 +388,8 @@ mod tests { #[test] #[ignore] fn send_recv_huge() { - let (mut postoffice, sock) = create_postoffice::<(), Vec>(3).unwrap(); + let (mut postoffice, bound) = create_postoffice::<(), Vec>(3).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let test_msgs: Vec> = (0..5) .map(|i| (0..100000).map(|j| i * 2 + j).collect()) .collect(); @@ -410,7 +413,8 @@ mod tests { #[test] fn send_recv_both() { - let (mut postoffice, sock) = create_postoffice::(4).unwrap(); + let (mut postoffice, bound) = create_postoffice::(4).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let mut client = PostBox::::to(sock).unwrap(); loop_for(Duration::from_millis(250), || ()); let mut server = postoffice.new_postboxes().next().unwrap();