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

muxers: Add test harness for StreamMuxer implementations #2952

Merged
merged 17 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"