Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-display-impl-on-queryid
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 10, 2023
2 parents 39d9fea + 2ecc7cf commit 772e7a1
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions libp2p/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.53.1 - unreleased

- Allow `SwarmBuilder::with_quic_config` to be called without `with_tcp` first.
See [PR 4821](https://github.com/libp2p/rust-libp2p/pull/4821).

## 0.53.0

- Raise MSRV to 1.73.
Expand Down
2 changes: 1 addition & 1 deletion libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021"
rust-version = { workspace = true }
description = "Peer-to-peer networking library"
version = "0.53.0"
version = "0.53.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
146 changes: 140 additions & 6 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,16 +120,60 @@ mod tests {
}

#[test]
#[cfg(all(feature = "tokio", feature = "tcp", feature = "tls", feature = "mplex"))]
#[cfg(all(feature = "tokio", feature = "quic"))]
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| config)
.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| config)
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
.unwrap()
.build();
}

#[test]
#[cfg(all(feature = "tokio", feature = "tcp", feature = "tls", feature = "yamux"))]
fn tcp_yamux_mplex() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Default::default(),
libp2p_tls::Config::new,
(
libp2p_yamux::Config::default(),
libp2p_mplex::MplexConfig::default(),
libp2p_yamux::Config::default,
libp2p_mplex::MplexConfig::default,
),
)
.unwrap()
Expand All @@ -132,7 +183,13 @@ 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"
))]
fn tcp_tls_noise() {
let _ = SwarmBuilder::with_new_identity()
.with_tokio()
Expand All @@ -156,6 +213,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "quic"
))]
fn tcp_quic() {
Expand All @@ -173,12 +231,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| 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| 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 +344,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "dns"
))]
async fn tcp_dns() {
Expand Down Expand Up @@ -260,6 +392,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "dns",
feature = "websocket",
))]
Expand Down Expand Up @@ -289,6 +422,7 @@ mod tests {
feature = "tcp",
feature = "tls",
feature = "noise",
feature = "yamux",
feature = "quic",
feature = "dns",
feature = "relay",
Expand Down
24 changes: 24 additions & 0 deletions libp2p/src/builder/phase/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,30 @@ impl SwarmBuilder<super::provider::Tokio, TcpPhase> {
self.without_tcp().with_quic()
}
}
#[cfg(all(not(target_arch = "wasm32"), feature = "quic", feature = "async-std"))]
impl SwarmBuilder<super::provider::AsyncStd, TcpPhase> {
pub fn with_quic_config(
self,
constructor: impl FnOnce(libp2p_quic::Config) -> libp2p_quic::Config,
) -> SwarmBuilder<
super::provider::AsyncStd,
OtherTransportPhase<impl AuthenticatedMultiplexedTransport>,
> {
self.without_tcp().with_quic_config(constructor)
}
}
#[cfg(all(not(target_arch = "wasm32"), feature = "quic", feature = "tokio"))]
impl SwarmBuilder<super::provider::Tokio, TcpPhase> {
pub fn with_quic_config(
self,
constructor: impl FnOnce(libp2p_quic::Config) -> libp2p_quic::Config,
) -> SwarmBuilder<
super::provider::Tokio,
OtherTransportPhase<impl AuthenticatedMultiplexedTransport>,
> {
self.without_tcp().with_quic_config(constructor)
}
}
impl<Provider> SwarmBuilder<Provider, TcpPhase> {
pub fn with_other_transport<
Muxer: libp2p_core::muxing::StreamMuxer + Send + 'static,
Expand Down

0 comments on commit 772e7a1

Please sign in to comment.