@@ -3138,9 +3138,9 @@ impl NetInfo {
3138
3138
#[ cfg( test) ]
3139
3139
mod tests {
3140
3140
use anyhow:: Context ;
3141
- use iroh_test:: CallOnDrop ;
3142
3141
use rand:: RngCore ;
3143
3142
use tokio_util:: task:: AbortOnDropHandle ;
3143
+ use tracing_test:: traced_test;
3144
3144
3145
3145
use super :: * ;
3146
3146
use crate :: {
@@ -3214,7 +3214,7 @@ mod tests {
3214
3214
///
3215
3215
/// When the returned drop guard is dropped, the tasks doing this updating are stopped.
3216
3216
#[ instrument( skip_all) ]
3217
- async fn mesh_stacks ( stacks : Vec < MagicStack > ) -> Result < CallOnDrop > {
3217
+ async fn mesh_stacks ( stacks : Vec < MagicStack > ) -> Result < JoinSet < ( ) > > {
3218
3218
/// Registers endpoint addresses of a node to all other nodes.
3219
3219
fn update_direct_addrs (
3220
3220
stacks : & [ MagicStack ] ,
@@ -3251,9 +3251,6 @@ mod tests {
3251
3251
}
3252
3252
} ) ;
3253
3253
}
3254
- let guard = CallOnDrop :: new ( move || {
3255
- tasks. abort_all ( ) ;
3256
- } ) ;
3257
3254
3258
3255
// Wait for all nodes to be registered with each other.
3259
3256
time:: timeout ( Duration :: from_secs ( 10 ) , async move {
@@ -3278,7 +3275,7 @@ mod tests {
3278
3275
. await
3279
3276
. context ( "failed to connect nodes" ) ?;
3280
3277
info ! ( "all nodes meshed" ) ;
3281
- Ok ( guard )
3278
+ Ok ( tasks )
3282
3279
}
3283
3280
3284
3281
#[ instrument( skip_all, fields( me = %ep. endpoint. node_id( ) . fmt_short( ) ) ) ]
@@ -3426,9 +3423,8 @@ mod tests {
3426
3423
}
3427
3424
3428
3425
#[ tokio:: test( flavor = "multi_thread" ) ]
3426
+ #[ traced_test]
3429
3427
async fn test_two_devices_roundtrip_quinn_magic ( ) -> Result < ( ) > {
3430
- iroh_test:: logging:: setup_multithreaded ( ) ;
3431
-
3432
3428
let m1 = MagicStack :: new ( RelayMode :: Disabled ) . await ?;
3433
3429
let m2 = MagicStack :: new ( RelayMode :: Disabled ) . await ?;
3434
3430
@@ -3462,9 +3458,9 @@ mod tests {
3462
3458
}
3463
3459
3464
3460
#[ tokio:: test]
3461
+ #[ traced_test]
3465
3462
async fn test_regression_network_change_rebind_wakes_connection_driver (
3466
3463
) -> testresult:: TestResult {
3467
- let _ = iroh_test:: logging:: setup ( ) ;
3468
3464
let m1 = MagicStack :: new ( RelayMode :: Disabled ) . await ?;
3469
3465
let m2 = MagicStack :: new ( RelayMode :: Disabled ) . await ?;
3470
3466
@@ -3501,6 +3497,7 @@ mod tests {
3501
3497
}
3502
3498
3503
3499
#[ tokio:: test( flavor = "multi_thread" ) ]
3500
+ #[ traced_test]
3504
3501
async fn test_two_devices_roundtrip_network_change ( ) -> Result < ( ) > {
3505
3502
time:: timeout (
3506
3503
Duration :: from_secs ( 90 ) ,
@@ -3512,8 +3509,6 @@ mod tests {
3512
3509
/// Same structure as `test_two_devices_roundtrip_quinn_magic`, but interrupts regularly
3513
3510
/// with (simulated) network changes.
3514
3511
async fn test_two_devices_roundtrip_network_change_impl ( ) -> Result < ( ) > {
3515
- iroh_test:: logging:: setup_multithreaded ( ) ;
3516
-
3517
3512
let m1 = MagicStack :: new ( RelayMode :: Disabled ) . await ?;
3518
3513
let m2 = MagicStack :: new ( RelayMode :: Disabled ) . await ?;
3519
3514
@@ -3535,9 +3530,7 @@ mod tests {
3535
3530
time:: sleep ( offset ( ) ) . await ;
3536
3531
}
3537
3532
} ) ;
3538
- CallOnDrop :: new ( move || {
3539
- task. abort ( ) ;
3540
- } )
3533
+ AbortOnDropHandle :: new ( task)
3541
3534
} ;
3542
3535
3543
3536
for i in 0 ..rounds {
@@ -3564,9 +3557,7 @@ mod tests {
3564
3557
time:: sleep ( offset ( ) ) . await ;
3565
3558
}
3566
3559
} ) ;
3567
- CallOnDrop :: new ( move || {
3568
- task. abort ( ) ;
3569
- } )
3560
+ AbortOnDropHandle :: new ( task)
3570
3561
} ;
3571
3562
3572
3563
for i in 0 ..rounds {
@@ -3594,9 +3585,7 @@ mod tests {
3594
3585
m2. endpoint . magic_sock ( ) . force_network_change ( true ) . await ;
3595
3586
time:: sleep ( offset ( ) ) . await ;
3596
3587
} ) ;
3597
- CallOnDrop :: new ( move || {
3598
- task. abort ( ) ;
3599
- } )
3588
+ AbortOnDropHandle :: new ( task)
3600
3589
} ;
3601
3590
3602
3591
for i in 0 ..rounds {
@@ -3616,8 +3605,8 @@ mod tests {
3616
3605
}
3617
3606
3618
3607
#[ tokio:: test( flavor = "multi_thread" ) ]
3608
+ #[ traced_test]
3619
3609
async fn test_two_devices_setup_teardown ( ) -> Result < ( ) > {
3620
- iroh_test:: logging:: setup_multithreaded ( ) ;
3621
3610
for i in 0 ..10 {
3622
3611
println ! ( "-- round {i}" ) ;
3623
3612
println ! ( "setting up magic stack" ) ;
@@ -3639,9 +3628,8 @@ mod tests {
3639
3628
}
3640
3629
3641
3630
#[ tokio:: test]
3631
+ #[ traced_test]
3642
3632
async fn test_two_devices_roundtrip_quinn_raw ( ) -> Result < ( ) > {
3643
- let _guard = iroh_test:: logging:: setup ( ) ;
3644
-
3645
3633
let make_conn = |addr : SocketAddr | -> anyhow:: Result < quinn:: Endpoint > {
3646
3634
let key = SecretKey :: generate ( rand:: thread_rng ( ) ) ;
3647
3635
let conn = std:: net:: UdpSocket :: bind ( addr) ?;
@@ -3788,9 +3776,8 @@ mod tests {
3788
3776
}
3789
3777
3790
3778
#[ tokio:: test]
3779
+ #[ traced_test]
3791
3780
async fn test_two_devices_roundtrip_quinn_rebinding_conn ( ) -> Result < ( ) > {
3792
- let _guard = iroh_test:: logging:: setup ( ) ;
3793
-
3794
3781
fn make_conn ( addr : SocketAddr ) -> anyhow:: Result < quinn:: Endpoint > {
3795
3782
let key = SecretKey :: generate ( rand:: thread_rng ( ) ) ;
3796
3783
let conn = UdpConn :: bind ( addr) ?;
@@ -3981,8 +3968,8 @@ mod tests {
3981
3968
}
3982
3969
3983
3970
#[ tokio:: test]
3971
+ #[ traced_test]
3984
3972
async fn test_local_endpoints ( ) {
3985
- let _guard = iroh_test:: logging:: setup ( ) ;
3986
3973
let ms = Handle :: new ( Default :: default ( ) ) . await . unwrap ( ) ;
3987
3974
3988
3975
// See if we can get endpoints.
@@ -4105,11 +4092,10 @@ mod tests {
4105
4092
}
4106
4093
4107
4094
#[ tokio:: test]
4095
+ #[ traced_test]
4108
4096
async fn test_try_send_no_send_addr ( ) {
4109
4097
// Regression test: if there is no send_addr we should keep being able to use the
4110
4098
// Endpoint.
4111
- let _guard = iroh_test:: logging:: setup ( ) ;
4112
-
4113
4099
let secret_key_1 = SecretKey :: from_bytes ( & [ 1u8 ; 32 ] ) ;
4114
4100
let secret_key_2 = SecretKey :: from_bytes ( & [ 2u8 ; 32 ] ) ;
4115
4101
let node_id_2 = secret_key_2. public ( ) ;
@@ -4196,11 +4182,10 @@ mod tests {
4196
4182
}
4197
4183
4198
4184
#[ tokio:: test]
4185
+ #[ traced_test]
4199
4186
async fn test_try_send_no_udp_addr_or_relay_url ( ) {
4200
4187
// This specifically tests the `if udp_addr.is_none() && relay_url.is_none()`
4201
4188
// behaviour of MagicSock::try_send.
4202
- let _logging_guard = iroh_test:: logging:: setup ( ) ;
4203
-
4204
4189
let secret_key_1 = SecretKey :: from_bytes ( & [ 1u8 ; 32 ] ) ;
4205
4190
let secret_key_2 = SecretKey :: from_bytes ( & [ 2u8 ; 32 ] ) ;
4206
4191
let node_id_2 = secret_key_2. public ( ) ;
0 commit comments