Skip to content

Commit

Permalink
chore(test-utils): revert #5725, with it we cannot publish the crates…
Browse files Browse the repository at this point in the history
… using test-utils
  • Loading branch information
jxs committed Jan 13, 2025
1 parent 3b514cb commit af07278
Show file tree
Hide file tree
Showing 53 changed files with 570 additions and 375 deletions.
480 changes: 258 additions & 222 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ members = [
"misc/quickcheck-ext",
"misc/rw-stream-sink",
"misc/server",
"misc/test-utils",
"misc/webrtc-utils",
"muxers/mplex",
"muxers/test-harness",
Expand Down Expand Up @@ -114,7 +113,6 @@ libp2p-websocket = { version = "0.44.1", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.4.1", path = "transports/websocket-websys" }
libp2p-webtransport-websys = { version = "0.4.1", path = "transports/webtransport-websys" }
libp2p-yamux = { version = "0.46.0", path = "muxers/yamux" }
libp2p-test-utils = { version = "0.1.0", path = "misc/test-utils" }

# External dependencies
async-std-resolver = { version = "0.25.0-alpha.4", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion misc/multistream-select/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async-std = { version = "1.6.2", features = ["attributes"] }
futures_ringbuf = "0.4.0"
quickcheck = { workspace = true }
rw-stream-sink = { workspace = true }
libp2p-test-utils = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

# Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling
Expand Down
14 changes: 8 additions & 6 deletions misc/multistream-select/src/dialer_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ mod tests {
future::timeout,
net::{TcpListener, TcpStream},
};
use libp2p_test_utils::EnvFilter;
use quickcheck::{Arbitrary, Gen, GenRange};
use tracing::metadata::LevelFilter;
use tracing_subscriber::EnvFilter;

use super::*;
use crate::listener_select_proto;
Expand Down Expand Up @@ -275,11 +275,13 @@ mod tests {
ListenerProtos(listen_protos): ListenerProtos,
DialPayload(dial_payload): DialPayload,
) {
libp2p_test_utils::with_env_filter(
EnvFilter::builder()
.with_default_directive(LevelFilter::DEBUG.into())
.from_env_lossy(),
);
let _ = tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::builder()
.with_default_directive(LevelFilter::DEBUG.into())
.from_env_lossy(),
)
.try_init();

async_std::task::block_on(async move {
let listener = TcpListener::bind("0.0.0.0:0").await.unwrap();
Expand Down
4 changes: 0 additions & 4 deletions misc/test-utils/CHANGELOG.md

This file was deleted.

17 changes: 0 additions & 17 deletions misc/test-utils/Cargo.toml

This file was deleted.

15 changes: 0 additions & 15 deletions misc/test-utils/src/lib.rs

This file was deleted.

2 changes: 1 addition & 1 deletion muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ libp2p-muxer-test-harness = { path = "../test-harness" }
libp2p-plaintext = { workspace = true }
libp2p-tcp = { workspace = true, features = ["async-io"] }
quickcheck = { workspace = true }
libp2p-test-utils = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[[bench]]
name = "split_send_size"
Expand Down
5 changes: 4 additions & 1 deletion muxers/mplex/benches/split_send_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use libp2p_identity as identity;
use libp2p_identity::PeerId;
use libp2p_mplex as mplex;
use libp2p_plaintext as plaintext;
use tracing_subscriber::EnvFilter;

type BenchTransport = transport::Boxed<(PeerId, muxing::StreamMuxerBox)>;

Expand All @@ -54,7 +55,9 @@ const BENCH_SIZES: [usize; 8] = [
];

fn prepare(c: &mut Criterion) {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let payload: Vec<u8> = vec![1; 1024 * 1024];

Expand Down
10 changes: 8 additions & 2 deletions muxers/mplex/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,10 @@ mod tests {

#[test]
fn max_buffer_behaviour() {
libp2p_test_utils::with_default_env_filter();
use tracing_subscriber::EnvFilter;
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

fn prop(cfg: MplexConfig, overflow: NonZeroU8) {
let mut r_buf = BytesMut::new();
Expand Down Expand Up @@ -1366,7 +1369,10 @@ mod tests {

#[test]
fn close_on_error() {
libp2p_test_utils::with_default_env_filter();
use tracing_subscriber::EnvFilter;
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

fn prop(cfg: MplexConfig, num_streams: NonZeroU8) {
let num_streams = cmp::min(cfg.max_substreams, num_streams.get() as usize);
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ thiserror = { workspace = true, optional = true }
[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt", "sync"] }
libp2p-swarm-test = { path = "../../swarm-test" }
libp2p-test-utils = { workspace = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
libp2p-identify = { workspace = true }
libp2p-swarm = { workspace = true, features = ["macros"] }

Expand Down
17 changes: 13 additions & 4 deletions protocols/autonat/tests/autonatv2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ use libp2p_swarm::{
use libp2p_swarm_test::SwarmExt;
use rand_core::OsRng;
use tokio::sync::oneshot;
use tracing_subscriber::EnvFilter;

#[tokio::test]
async fn confirm_successful() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();
let (mut alice, mut bob) = start_and_connect().await;

let cor_server_peer = *alice.local_peer_id();
Expand Down Expand Up @@ -125,7 +128,9 @@ async fn confirm_successful() {

#[tokio::test]
async fn dial_back_to_unsupported_protocol() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();
let (mut alice, mut bob) = bootstrap().await;

let alice_peer_id = *alice.local_peer_id();
Expand Down Expand Up @@ -221,7 +226,9 @@ async fn dial_back_to_unsupported_protocol() {

#[tokio::test]
async fn dial_back_to_non_libp2p() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();
let (mut alice, mut bob) = bootstrap().await;
let alice_peer_id = *alice.local_peer_id();

Expand Down Expand Up @@ -307,7 +314,9 @@ async fn dial_back_to_non_libp2p() {

#[tokio::test]
async fn dial_back_to_not_supporting() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let (mut alice, mut bob) = bootstrap().await;
let alice_peer_id = *alice.local_peer_id();
Expand Down
2 changes: 1 addition & 1 deletion protocols/dcutr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ libp2p-swarm = { workspace = true, features = ["macros"] }
libp2p-swarm-test = { path = "../../swarm-test" }
libp2p-tcp = { workspace = true, features = ["async-io"] }
libp2p-yamux = { workspace = true }
libp2p-test-utils = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
tokio = { workspace = true, features = ["rt", "macros"] }

# Passing arguments to the docsrs builder in order to properly document cfg's.
Expand Down
5 changes: 4 additions & 1 deletion protocols/dcutr/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ use libp2p_plaintext as plaintext;
use libp2p_relay as relay;
use libp2p_swarm::{Config, NetworkBehaviour, Swarm, SwarmEvent};
use libp2p_swarm_test::SwarmExt as _;
use tracing_subscriber::EnvFilter;

#[tokio::test]
async fn connect() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut relay = build_relay();
let mut dst = build_client();
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ prometheus-client = { workspace = true }
libp2p-core = { workspace = true }
libp2p-swarm-test = { path = "../../swarm-test" }
quickcheck = { workspace = true }
libp2p-test-utils = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "time", "macros"] }

# Passing arguments to the docsrs builder in order to properly document cfg's.
Expand Down
5 changes: 4 additions & 1 deletion protocols/gossipsub/src/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4766,7 +4766,10 @@ fn test_limit_number_of_message_ids_inside_ihave() {

#[test]
fn test_iwant_penalties() {
libp2p_test_utils::with_default_env_filter();
// use tracing_subscriber::EnvFilter;
// let _ = tracing_subscriber::fmt()
// .with_env_filter(EnvFilter::from_default_env())
// .try_init();
let config = ConfigBuilder::default()
.iwant_followup_time(Duration::from_secs(4))
.build()
Expand Down
5 changes: 4 additions & 1 deletion protocols/gossipsub/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use libp2p_swarm_test::SwarmExt as _;
use quickcheck::{QuickCheck, TestResult};
use rand::{seq::SliceRandom, SeedableRng};
use tokio::{runtime::Runtime, time};
use tracing_subscriber::EnvFilter;

struct Graph {
nodes: SelectAll<Swarm<gossipsub::Behaviour>>,
Expand Down Expand Up @@ -131,7 +132,9 @@ async fn build_node() -> Swarm<gossipsub::Behaviour> {

#[test]
fn multi_hop_propagation() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

fn prop(num_nodes: u8, seed: u64) -> TestResult {
if !(2..=50).contains(&num_nodes) {
Expand Down
2 changes: 1 addition & 1 deletion protocols/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ either = "1.12.0"
async-std = { version = "1.6.2", features = ["attributes"] }
libp2p-swarm-test = { path = "../../swarm-test" }
libp2p-swarm = { workspace = true, features = ["macros"] }
libp2p-test-utils = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

# Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling
Expand Down
33 changes: 25 additions & 8 deletions protocols/identify/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ use libp2p_identify as identify;
use libp2p_identity::Keypair;
use libp2p_swarm::{Swarm, SwarmEvent};
use libp2p_swarm_test::SwarmExt;
use tracing_subscriber::EnvFilter;

#[async_std::test]
async fn periodic_identify() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm1 = Swarm::new_ephemeral(|identity| {
identify::Behaviour::new(
Expand Down Expand Up @@ -81,7 +84,9 @@ async fn periodic_identify() {
}
#[async_std::test]
async fn only_emits_address_candidate_once_per_connection() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm1 = Swarm::new_ephemeral(|identity| {
identify::Behaviour::new(
Expand Down Expand Up @@ -151,7 +156,9 @@ async fn only_emits_address_candidate_once_per_connection() {

#[async_std::test]
async fn emits_unique_listen_addresses() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm1 = Swarm::new_ephemeral(|identity| {
identify::Behaviour::new(
Expand Down Expand Up @@ -221,7 +228,9 @@ async fn emits_unique_listen_addresses() {

#[async_std::test]
async fn hides_listen_addresses() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm1 = Swarm::new_ephemeral(|identity| {
identify::Behaviour::new(
Expand Down Expand Up @@ -290,7 +299,9 @@ async fn hides_listen_addresses() {

#[async_std::test]
async fn identify_push() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm1 = Swarm::new_ephemeral(|identity| {
identify::Behaviour::new(identify::Config::new("a".to_string(), identity.public()))
Expand Down Expand Up @@ -340,7 +351,9 @@ async fn identify_push() {

#[async_std::test]
async fn discover_peer_after_disconnect() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm1 = Swarm::new_ephemeral(|identity| {
identify::Behaviour::new(identify::Config::new("a".to_string(), identity.public()))
Expand Down Expand Up @@ -391,7 +404,9 @@ async fn discover_peer_after_disconnect() {

#[async_std::test]
async fn configured_interval_starts_after_first_identify() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let identify_interval = Duration::from_secs(5);

Expand Down Expand Up @@ -429,7 +444,9 @@ async fn configured_interval_starts_after_first_identify() {

#[async_std::test]
async fn reject_mismatched_public_key() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut honest_swarm = Swarm::new_ephemeral(|identity| {
identify::Behaviour::new(
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ libp2p-swarm = { path = "../../swarm", features = ["macros"] }
libp2p-swarm-test = { path = "../../swarm-test" }
libp2p-yamux = { workspace = true }
quickcheck = { workspace = true }
libp2p-test-utils = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[features]
serde = ["dep:serde", "bytes/serde"]
Expand Down
4 changes: 3 additions & 1 deletion protocols/kad/src/behaviour/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ fn query_iter() {

#[test]
fn unresponsive_not_returned_direct() {
libp2p_test_utils::with_default_env_filter();
let _ = tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.try_init();
// Build one node. It contains fake addresses to non-existing nodes. We ask it to find a
// random peer. We make sure that no fake address is returned.

Expand Down
Loading

0 comments on commit af07278

Please sign in to comment.