Skip to content

Commit 8911660

Browse files
author
Alex J Lennon
committed
fix(test): replay integration connect via loopback on Windows
ProxyServer binds 0.0.0.0; local_addr() is unspec and TcpStream::connect to 0.0.0.0 fails with WSAEADDRNOTAVAIL (10049) on Windows. Use same connect_addr helper as proxy_integration tests. Made-with: Cursor
1 parent 1cdecfd commit 8911660

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

tests/replay_integration.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,23 @@ use rsgdb::protocol::codec::{GdbCodec, PacketOrAck};
66
use rsgdb::protocol::Packet;
77
use rsgdb::proxy::ProxyServer;
88
use rsgdb::recorder::{RecordDirection, RecordEventV1};
9+
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
910
use tokio::net::{TcpListener, TcpStream};
1011
use tokio_util::codec::Framed;
1112

13+
/// Same as `proxy_integration`: listeners on `0.0.0.0` must be reached via loopback on Windows.
14+
fn connect_addr(listen: SocketAddr) -> SocketAddr {
15+
match listen {
16+
SocketAddr::V4(a) if a.ip().is_unspecified() => {
17+
SocketAddr::new(Ipv4Addr::LOCALHOST.into(), a.port())
18+
}
19+
SocketAddr::V6(a) if a.ip().is_unspecified() => {
20+
SocketAddr::new(Ipv6Addr::LOCALHOST.into(), a.port())
21+
}
22+
_ => listen,
23+
}
24+
}
25+
1226
#[tokio::test]
1327
async fn replay_mock_backend_round_trip_through_proxy() {
1428
let events = vec![
@@ -53,7 +67,7 @@ async fn replay_mock_backend_round_trip_through_proxy() {
5367

5468
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
5569

56-
let client = TcpStream::connect(proxy_addr)
70+
let client = TcpStream::connect(connect_addr(proxy_addr))
5771
.await
5872
.expect("connect to proxy");
5973
let mut framed = Framed::new(client, GdbCodec::new());

0 commit comments

Comments
 (0)