Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add SwarmBuilder::with_quic_config for TcpPhase #4821

Merged
merged 6 commits into from
Nov 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 145 additions & 4 deletions libp2p/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ mod tests {
use libp2p_swarm::{NetworkBehaviour, Swarm};

#[test]
#[cfg(all(feature = "tokio", feature = "tcp", feature = "tls", feature = "noise"))]
#[cfg(all(
feature = "tokio",
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
))]
fn tcp() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
Expand All @@ -96,7 +102,8 @@ mod tests {
feature = "async-std",
feature = "tcp",
feature = "tls",
feature = "noise"
feature = "noise",
feature = "yamux",
))]
fn async_std_tcp() {
let _ = SwarmBuilder::with_new_identity()
Expand All @@ -113,7 +120,57 @@ mod tests {
}

#[test]
#[cfg(all(feature = "tokio", feature = "tcp", feature = "tls", feature = "mplex"))]
#[cfg(all(feature = "tokio", feature = "quic"))]
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
fn quic() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
.with_quic()
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(feature = "async-std", feature = "quic"))]
fn async_std_quic() {
let _ = SwarmBuilder::with_new_identity()
.with_async_std()
.with_quic()
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(feature = "tokio", feature = "quic"))]
fn quic_config() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
.with_quic_config(|config: libp2p_quic::Config| config)
oblique marked this conversation as resolved.
Show resolved Hide resolved
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(feature = "async-std", feature = "quic"))]
fn async_std_quic_config() {
let _ = SwarmBuilder::with_new_identity()
.with_async_std()
.with_quic_config(|config: libp2p_quic::Config| config)
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(
feature = "tokio",
feature = "tcp",
feature = "tls",
feature = "yamux",
feature = "mplex"
))]
fn tcp_yamux_mplex() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
Expand All @@ -132,7 +189,14 @@ mod tests {
}

#[test]
#[cfg(all(feature = "tokio", feature = "tcp", feature = "tls", feature = "noise"))]
#[cfg(all(
feature = "tokio",
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "mplex",
))]
fn tcp_tls_noise() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
Expand All @@ -156,6 +220,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "quic"
))]
fn tcp_quic() {
Expand All @@ -173,12 +238,85 @@ mod tests {
.build();
}

#[test]
#[cfg(all(
feature = "async-std",
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "quic"
))]
fn async_std_tcp_quic() {
let _ = SwarmBuilder::with_new_identity()
.with_async_std()
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)
.unwrap()
.with_quic()
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(
feature = "tokio",
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "quic"
))]
fn tcp_quic_config() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)
.unwrap()
.with_quic_config(|config: libp2p_quic::Config| config)
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(
feature = "async-std",
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "quic"
))]
fn async_std_tcp_quic_config() {
let _ = SwarmBuilder::with_new_identity()
.with_async_std()
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)
.unwrap()
.with_quic_config(|config: libp2p_quic::Config| config)
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(
feature = "tokio",
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "relay"
))]
fn tcp_relay() {
Expand Down Expand Up @@ -213,6 +351,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "dns"
))]
async fn tcp_dns() {
Expand Down Expand Up @@ -260,6 +399,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "dns",
feature = "websocket",
))]
Expand Down Expand Up @@ -289,6 +429,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "quic",
feature = "dns",
feature = "relay",
Expand Down