Skip to content

Commit c78de35

Browse files
authored
chore(identify): migrate tests from async-std to tokio
Migrating tests in `protocols/identify` from `async_std` to `tokio` as per #4449 Pull-Request: #5849.
1 parent da8763c commit c78de35

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocols/identify/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tracing = { workspace = true }
2626
either = "1.12.0"
2727

2828
[dev-dependencies]
29-
async-std = { version = "1.6.2", features = ["attributes"] }
29+
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
3030
libp2p-swarm-test = { path = "../../swarm-test" }
3131
libp2p-swarm = { workspace = true, features = ["macros"] }
3232
tracing-subscriber = { workspace = true, features = ["env-filter"] }

protocols/identify/tests/smoke.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use libp2p_swarm::{Swarm, SwarmEvent};
1111
use libp2p_swarm_test::SwarmExt;
1212
use tracing_subscriber::EnvFilter;
1313

14-
#[async_std::test]
14+
#[tokio::test]
1515
async fn periodic_identify() {
1616
let _ = tracing_subscriber::fmt()
1717
.with_env_filter(EnvFilter::from_default_env())
@@ -82,7 +82,7 @@ async fn periodic_identify() {
8282
other => panic!("Unexpected events: {other:?}"),
8383
}
8484
}
85-
#[async_std::test]
85+
#[tokio::test]
8686
async fn only_emits_address_candidate_once_per_connection() {
8787
let _ = tracing_subscriber::fmt()
8888
.with_env_filter(EnvFilter::from_default_env())
@@ -105,7 +105,7 @@ async fn only_emits_address_candidate_once_per_connection() {
105105
swarm2.listen().with_memory_addr_external().await;
106106
swarm1.connect(&mut swarm2).await;
107107

108-
async_std::task::spawn(swarm2.loop_on_next());
108+
tokio::spawn(swarm2.loop_on_next());
109109

110110
let swarm_events = futures::stream::poll_fn(|cx| swarm1.poll_next_unpin(cx))
111111
.take(8)
@@ -154,7 +154,7 @@ async fn only_emits_address_candidate_once_per_connection() {
154154
);
155155
}
156156

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

183-
async_std::task::spawn(swarm2.loop_on_next());
183+
tokio::spawn(swarm2.loop_on_next());
184184

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

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

256-
async_std::task::spawn(swarm2.loop_on_next());
256+
tokio::spawn(swarm2.loop_on_next());
257257

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

300-
#[async_std::test]
300+
#[tokio::test]
301301
async fn identify_push() {
302302
let _ = tracing_subscriber::fmt()
303303
.with_env_filter(EnvFilter::from_default_env())
@@ -349,7 +349,7 @@ async fn identify_push() {
349349
assert!(swarm1_received_info.listen_addrs.is_empty());
350350
}
351351

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

371371
let swarm1_peer_id = *swarm1.local_peer_id();
372-
async_std::task::spawn(swarm1.loop_on_next());
372+
tokio::spawn(swarm1.loop_on_next());
373373

374374
// Wait until we identified.
375375
swarm2
@@ -402,7 +402,7 @@ async fn discover_peer_after_disconnect() {
402402
assert_eq!(connected_peer, swarm1_peer_id);
403403
}
404404

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

429-
async_std::task::spawn(swarm2.loop_on_next());
429+
tokio::spawn(swarm2.loop_on_next());
430430

431431
let start = Instant::now();
432432

@@ -442,7 +442,7 @@ async fn configured_interval_starts_after_first_identify() {
442442
assert!(time_to_first_identify < identify_interval)
443443
}
444444

445-
#[async_std::test]
445+
#[tokio::test]
446446
async fn reject_mismatched_public_key() {
447447
let _ = tracing_subscriber::fmt()
448448
.with_env_filter(EnvFilter::from_default_env())

0 commit comments

Comments
 (0)