Skip to content

Commit 5bb2266

Browse files
committed
ci: use IPv4 by default
`localhost` appears not to be mapped to `[::1]` in GitHub Actions Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 36857d5 commit 5bb2266

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

crates/test/src/lib.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use std::net::Ipv6Addr;
1+
use core::net::{Ipv4Addr, Ipv6Addr};
2+
23
use std::process::ExitStatus;
34

45
use anyhow::Context;
@@ -79,28 +80,22 @@ where
7980

8081
#[cfg(feature = "quic")]
8182
pub async fn with_quic_endpoints<T, Fut>(
82-
f: impl FnOnce(std::net::SocketAddr, quinn::Endpoint, quinn::Endpoint) -> Fut,
83+
f: impl FnOnce(core::net::SocketAddr, quinn::Endpoint, quinn::Endpoint) -> Fut,
8384
) -> anyhow::Result<T>
8485
where
8586
Fut: core::future::Future<Output = anyhow::Result<T>>,
8687
{
8788
use std::sync::Arc;
8889

8990
use quinn::crypto::rustls::QuicClientConfig;
90-
use quinn::{ClientConfig, EndpointConfig, ServerConfig, TokioRuntime};
91+
use quinn::{ClientConfig, ServerConfig};
9192
use rcgen::{generate_simple_self_signed, CertifiedKey};
9293
use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer};
9394
use rustls::version::TLS13;
9495

95-
let mut clt_ep = quinn::Endpoint::client((Ipv6Addr::LOCALHOST, 0).into())
96+
let mut clt_ep = quinn::Endpoint::client((Ipv4Addr::LOCALHOST, 0).into())
9697
.context("failed to create client endpoint")?;
9798

98-
let srv_sock = std::net::UdpSocket::bind((Ipv6Addr::LOCALHOST, 0))
99-
.context("failed to open a UDP socket")?;
100-
let srv_addr = srv_sock
101-
.local_addr()
102-
.context("failed to query server address")?;
103-
10499
let CertifiedKey {
105100
cert: srv_crt,
106101
key_pair: srv_key,
@@ -132,13 +127,11 @@ where
132127
.expect("failed to create server config");
133128

134129
clt_ep.set_default_client_config(ClientConfig::new(Arc::new(clt_cnf)));
135-
let srv_ep = quinn::Endpoint::new(
136-
EndpointConfig::default(),
137-
Some(srv_cnf),
138-
srv_sock,
139-
Arc::new(TokioRuntime),
140-
)
141-
.context("failed to create server endpoint")?;
130+
let srv_ep = quinn::Endpoint::server(srv_cnf, (Ipv4Addr::LOCALHOST, 0).into())
131+
.context("failed to create server endpoint")?;
132+
let srv_addr = srv_ep
133+
.local_addr()
134+
.context("failed to query server address")?;
142135

143136
f(srv_addr, clt_ep, srv_ep).await.context("closure failed")
144137
}
@@ -180,7 +173,13 @@ where
180173
.context("failed to construct URL")?;
181174
let (clt, srv) = tokio::try_join!(
182175
async move {
183-
web_transport_quinn::connect(&clt, &url)
176+
let conn = clt
177+
.connect(addr, "localhost")
178+
.context("failed to connect to server")?;
179+
let conn = conn
180+
.await
181+
.context("failed to establish client connection")?;
182+
web_transport_quinn::connect_with(conn, &url)
184183
.await
185184
.context("failed to connect to server")
186185
},

0 commit comments

Comments
 (0)