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

chore(identify): migrate tests from async-std to tokio #5849

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


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

2 changes: 1 addition & 1 deletion protocols/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tracing = { workspace = true }
either = "1.12.0"

[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
libp2p-swarm-test = { path = "../../swarm-test" }
libp2p-swarm = { workspace = true, features = ["macros"] }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
Expand Down
26 changes: 13 additions & 13 deletions protocols/identify/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use libp2p_swarm::{Swarm, SwarmEvent};
use libp2p_swarm_test::SwarmExt;
use tracing_subscriber::EnvFilter;

#[async_std::test]
#[tokio::test]
async fn periodic_identify() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand Down Expand Up @@ -82,7 +82,7 @@ async fn periodic_identify() {
other => panic!("Unexpected events: {other:?}"),
}
}
#[async_std::test]
#[tokio::test]
async fn only_emits_address_candidate_once_per_connection() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand All @@ -105,7 +105,7 @@ async fn only_emits_address_candidate_once_per_connection() {
swarm2.listen().with_memory_addr_external().await;
swarm1.connect(&mut swarm2).await;

async_std::task::spawn(swarm2.loop_on_next());
tokio::spawn(swarm2.loop_on_next());

let swarm_events = futures::stream::poll_fn(|cx| swarm1.poll_next_unpin(cx))
.take(8)
Expand Down Expand Up @@ -154,7 +154,7 @@ async fn only_emits_address_candidate_once_per_connection() {
);
}

#[async_std::test]
#[tokio::test]
async fn emits_unique_listen_addresses() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand All @@ -180,7 +180,7 @@ async fn emits_unique_listen_addresses() {
let swarm2_peer_id = *swarm2.local_peer_id();
swarm1.connect(&mut swarm2).await;

async_std::task::spawn(swarm2.loop_on_next());
tokio::spawn(swarm2.loop_on_next());

let swarm_events = futures::stream::poll_fn(|cx| swarm1.poll_next_unpin(cx))
.take(8)
Expand Down Expand Up @@ -226,7 +226,7 @@ async fn emits_unique_listen_addresses() {
assert!(reported_addrs.contains(&(swarm2_peer_id, swarm2_tcp_listen_addr)));
}

#[async_std::test]
#[tokio::test]
async fn hides_listen_addresses() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand All @@ -253,7 +253,7 @@ async fn hides_listen_addresses() {
let swarm2_peer_id = *swarm2.local_peer_id();
swarm1.connect(&mut swarm2).await;

async_std::task::spawn(swarm2.loop_on_next());
tokio::spawn(swarm2.loop_on_next());

let swarm_events = futures::stream::poll_fn(|cx| swarm1.poll_next_unpin(cx))
.take(8)
Expand Down Expand Up @@ -297,7 +297,7 @@ async fn hides_listen_addresses() {
assert!(reported_addrs.contains(&(swarm2_peer_id, swarm2_tcp_listen_addr)));
}

#[async_std::test]
#[tokio::test]
async fn identify_push() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand Down Expand Up @@ -349,7 +349,7 @@ async fn identify_push() {
assert!(swarm1_received_info.listen_addrs.is_empty());
}

#[async_std::test]
#[tokio::test]
async fn discover_peer_after_disconnect() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand All @@ -369,7 +369,7 @@ async fn discover_peer_after_disconnect() {
swarm2.connect(&mut swarm1).await;

let swarm1_peer_id = *swarm1.local_peer_id();
async_std::task::spawn(swarm1.loop_on_next());
tokio::spawn(swarm1.loop_on_next());

// Wait until we identified.
swarm2
Expand Down Expand Up @@ -402,7 +402,7 @@ async fn discover_peer_after_disconnect() {
assert_eq!(connected_peer, swarm1_peer_id);
}

#[async_std::test]
#[tokio::test]
async fn configured_interval_starts_after_first_identify() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand All @@ -426,7 +426,7 @@ async fn configured_interval_starts_after_first_identify() {
swarm1.listen().with_memory_addr_external().await;
swarm2.connect(&mut swarm1).await;

async_std::task::spawn(swarm2.loop_on_next());
tokio::spawn(swarm2.loop_on_next());

let start = Instant::now();

Expand All @@ -442,7 +442,7 @@ async fn configured_interval_starts_after_first_identify() {
assert!(time_to_first_identify < identify_interval)
}

#[async_std::test]
#[tokio::test]
async fn reject_mismatched_public_key() {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand Down