Skip to content

Commit

Permalink
Bail on mplex
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Sep 3, 2023
1 parent a39a177 commit 97bf535
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions interop-tests/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) mod native {
use libp2p_webrtc as webrtc;
use redis::AsyncCommands;

use crate::{from_env, SecProtocol, Transport};
use crate::{from_env, Muxer, SecProtocol, Transport};

pub(crate) type Instant = std::time::Instant;

Expand All @@ -35,6 +35,15 @@ pub(crate) mod native {
tokio::time::sleep(duration).boxed()
}

fn expect_muxer_yamux() -> Result<()> {
Ok(match from_env("muxer")? {
Muxer::Yamux => (),
Muxer::Mplex => {
bail!("Only Yamux is supported, not Mplex")
}
})
}

// TODO: Error in case muxer is not yamux.
pub(crate) async fn build_swarm<B: NetworkBehaviour>(
ip: &str,
Expand All @@ -51,7 +60,8 @@ pub(crate) mod native {
(swarm, format!("/ip4/{ip}/udp/0/quic-v1"))
}
(Transport::Tcp, Ok(SecProtocol::Tls)) => {
// TODO: Note that the timeout of 5 secs is gone now.
expect_muxer_yamux()?;

let swarm = libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp()
Expand All @@ -61,7 +71,8 @@ pub(crate) mod native {
(swarm, format!("/ip4/{ip}/tcp/0"))
}
(Transport::Tcp, Ok(SecProtocol::Noise)) => {
// TODO: Note that the timeout of 5 secs is gone now.
expect_muxer_yamux()?;

let swarm = libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp()
Expand All @@ -71,6 +82,8 @@ pub(crate) mod native {
(swarm, format!("/ip4/{ip}/tcp/0"))
}
(Transport::Ws, Ok(SecProtocol::Tls)) => {
expect_muxer_yamux()?;

let swarm = libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
.with_websocket()
Expand All @@ -82,6 +95,8 @@ pub(crate) mod native {
(swarm, format!("/ip4/{ip}/tcp/0/ws"))
}
(Transport::Ws, Ok(SecProtocol::Noise)) => {
expect_muxer_yamux()?;

let swarm = libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
.with_websocket()
Expand Down

0 comments on commit 97bf535

Please sign in to comment.