Skip to content

Commit

Permalink
muxers: Add test harness for StreamMuxer implementations (#2952)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger authored Oct 17, 2022
1 parent 981d586 commit 4d4833f
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 305 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ members = [
"misc/quickcheck-ext",
"muxers/mplex",
"muxers/yamux",
"muxers/test-harness",
"protocols/dcutr",
"protocols/autonat",
"protocols/floodsub",
Expand Down
3 changes: 2 additions & 1 deletion muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ smallvec = "1.6.1"
unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }

[dev-dependencies]
async-std = "1.7.0"
async-std = { version = "1.7.0", features = ["attributes"] }
criterion = "0.4"
env_logger = "0.9"
futures = "0.3"
libp2p = { path = "../..", features = ["full"] }
libp2p-muxer-test-harness = { path = "../test-harness" }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }

[[bench]]
Expand Down
91 changes: 0 additions & 91 deletions muxers/mplex/tests/async_write.rs

This file was deleted.

28 changes: 28 additions & 0 deletions muxers/mplex/tests/compliance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use libp2p_mplex::MplexConfig;

#[async_std::test]
async fn close_implies_flush() {
let (alice, bob) =
libp2p_muxer_test_harness::connected_muxers_on_memory_transport::<MplexConfig, _, _>()
.await;

libp2p_muxer_test_harness::close_implies_flush(alice, bob).await;
}

#[async_std::test]
async fn dialer_can_receive() {
let (alice, bob) =
libp2p_muxer_test_harness::connected_muxers_on_memory_transport::<MplexConfig, _, _>()
.await;

libp2p_muxer_test_harness::dialer_can_receive(alice, bob).await;
}

#[async_std::test]
async fn read_after_close() {
let (alice, bob) =
libp2p_muxer_test_harness::connected_muxers_on_memory_transport::<MplexConfig, _, _>()
.await;

libp2p_muxer_test_harness::read_after_close(alice, bob).await;
}
213 changes: 0 additions & 213 deletions muxers/mplex/tests/two_peers.rs

This file was deleted.

14 changes: 14 additions & 0 deletions muxers/test-harness/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "libp2p-muxer-test-harness"
version = "0.1.0"
edition = "2021"
publish = false
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libp2p-core = { path = "../../core" }
futures = "0.3.24"
log = "0.4"
futures-timer = "3.0.2"
Loading

0 comments on commit 4d4833f

Please sign in to comment.