File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -804,4 +804,30 @@ mod tests {
804804 shutdown_routers ( routers) . await ;
805805 Ok ( ( ) )
806806 }
807+
808+ /// Check that when a connection is closed, the pool will give you a new
809+ /// connection next time you want one.
810+ ///
811+ /// This test fails if the connection watch is disabled.
812+ #[ tokio:: test]
813+ #[ traced_test]
814+ async fn watch_close ( ) -> TestResult < ( ) > {
815+ let n = 1 ;
816+ let ( ids, routers, discovery) = echo_servers ( n) . await ?;
817+ let endpoint = iroh:: Endpoint :: builder ( )
818+ . discovery ( discovery)
819+ . bind ( )
820+ . await ?;
821+
822+ let pool = ConnectionPool :: new ( endpoint, ECHO_ALPN , test_options ( ) ) ;
823+ let conn = pool. get_or_connect ( ids[ 0 ] ) . await ?;
824+ let cid1 = conn. stable_id ( ) ;
825+ conn. close ( 0u32 . into ( ) , b"test" ) ;
826+ tokio:: time:: sleep ( Duration :: from_millis ( 500 ) ) . await ;
827+ let conn = pool. get_or_connect ( ids[ 0 ] ) . await ?;
828+ let cid2 = conn. stable_id ( ) ;
829+ assert_ne ! ( cid1, cid2) ;
830+ shutdown_routers ( routers) . await ;
831+ Ok ( ( ) )
832+ }
807833}
You can’t perform that action at this time.
0 commit comments