@@ -3218,11 +3218,17 @@ mod tests {
32183218 }
32193219
32203220 /// Test that we can immediately reconnect after respawning an endpoint with the same node id.
3221+ ///
3222+ /// Importantly, this test does not use a relay. This means there is no other path but the UDP
3223+ /// path available. The respawned endpoint will have different direct addrs from the previous
3224+ /// endpoint. The test attempts to ensure that this works, i.e. that the server endpoint will
3225+ /// reply to the new addresses and not keep sending to the old UDP addresses which won't be
3226+ /// received anymore.
32213227 #[ tokio:: test]
32223228 #[ traced_test]
32233229 async fn can_abort_and_reconnect ( ) -> Result {
32243230 const TEST_ALPN : & [ u8 ] = b"/iroh/test/1" ;
3225- const TIMEOUT : Duration = Duration :: from_secs ( 5 ) ;
3231+ const TIMEOUT : Duration = Duration :: from_secs ( 10 ) ;
32263232
32273233 let mut rng = & mut rand_chacha:: ChaCha12Rng :: seed_from_u64 ( 1 ) ;
32283234
@@ -3241,10 +3247,15 @@ mod tests {
32413247 let server_loop = tokio:: task:: spawn ( async move {
32423248 while let Some ( conn) = server. accept ( ) . await {
32433249 let conn = conn. accept ( ) . e ( ) ?. await . e ( ) ?;
3250+ info ! ( "server ACCEPT" ) ;
3251+ let mut stream = conn. open_uni ( ) . await . e ( ) ?;
3252+ stream. write_all ( b"hi" ) . await . e ( ) ?;
3253+ stream. finish ( ) . e ( ) ?;
32443254 let res = match conn. closed ( ) . await {
32453255 ConnectionError :: ApplicationClosed ( frame) => Ok ( u64:: from ( frame. error_code ) ) ,
32463256 reason => Err ( reason) ,
32473257 } ;
3258+ info ! ( "server CLOSED" ) ;
32483259 tx. send ( res) . await . e ( ) ?;
32493260 }
32503261 Result :: < _ , n0_snafu:: Error > :: Ok ( ( ) )
@@ -3259,13 +3270,16 @@ mod tests {
32593270 . relay_mode ( RelayMode :: Disabled )
32603271 . bind ( )
32613272 . await ?;
3262- info ! (
3263- "connect client {} ({:?}) to {addr:?}" ,
3264- ep. node_id( ) . fmt_short( ) ,
3265- ep. bound_sockets( ) ,
3266- ) ;
3273+ let ipv4 = ep. bound_sockets ( ) [ 0 ] ;
3274+ let node_id = ep. node_id ( ) . fmt_short ( ) ;
3275+ info ! ( %node_id, %ipv4, "client CONNECT" ) ;
32673276 let conn = ep. connect ( addr, TEST_ALPN ) . await ?;
3277+ info ! ( %node_id, %ipv4, "client CONNECTED" ) ;
3278+ let mut stream = conn. accept_uni ( ) . await . e ( ) ?;
3279+ let buf = stream. read_to_end ( 2 ) . await . e ( ) ?;
3280+ assert_eq ! ( & buf, b"hi" ) ;
32683281 conn. close ( code. into ( ) , b"bye" ) ;
3282+ info ! ( %node_id, %ipv4, "client CLOSE" ) ;
32693283 Ok ( ep)
32703284 }
32713285
@@ -3279,8 +3293,7 @@ mod tests {
32793293 . await
32803294 . e ( ) ??;
32813295 assert_eq ! ( rx. recv( ) . await . unwrap( ) . unwrap( ) , 23 ) ;
3282- // close the endpoint in a separate task, to not lose time for our immediate respawn testing
3283- let close1 = tokio:: task:: spawn ( async move { ep. close ( ) . await } ) ;
3296+ ep. close ( ) . await ;
32843297
32853298 // Second connection
32863299 let ep = n0_future:: time:: timeout (
@@ -3290,9 +3303,8 @@ mod tests {
32903303 . await
32913304 . e ( ) ??;
32923305 assert_eq ! ( rx. recv( ) . await . unwrap( ) . unwrap( ) , 24 ) ;
3293-
3294- close1. await . e ( ) ?;
32953306 ep. close ( ) . await ;
3307+
32963308 server_loop. abort ( ) ;
32973309
32983310 Ok ( ( ) )
0 commit comments