@@ -11,7 +11,7 @@ use n0_snafu::ResultExt;
1111use testresult:: TestResult ;
1212use tracing:: trace;
1313
14- use crate :: connection_pool:: { ConnectionPool , ConnectionPoolError , Options , PoolConnectError } ;
14+ use crate :: connection_pool:: { ConnectionPool , Options , PoolConnectError } ;
1515
1616const ECHO_ALPN : & [ u8 ] = b"echo" ;
1717
@@ -92,27 +92,23 @@ impl EchoClient {
9292 & self ,
9393 id : NodeId ,
9494 text : Vec < u8 > ,
95- ) -> Result <
96- Result < Result < ( usize , Vec < u8 > ) , n0_snafu:: Error > , PoolConnectError > ,
97- ConnectionPoolError ,
98- > {
95+ ) -> Result < Result < ( usize , Vec < u8 > ) , n0_snafu:: Error > , PoolConnectError > {
9996 let conn = self . pool . connect ( id) . await ?;
100- let conn = match conn {
101- Ok ( conn) => conn,
102- Err ( e) => return Ok ( Err ( e) ) ,
103- } ;
10497 let id = conn. stable_id ( ) ;
10598 match echo_client ( & conn, & text) . await {
106- Ok ( res) => Ok ( Ok ( Ok ( ( id, res) ) ) ) ,
107- Err ( e) => Ok ( Ok ( Err ( e) ) ) ,
99+ Ok ( res) => Ok ( Ok ( ( id, res) ) ) ,
100+ Err ( e) => Ok ( Err ( e) ) ,
108101 }
109102 }
110103}
111104
112105#[ tokio:: test]
113106async fn connection_pool_errors ( ) -> TestResult < ( ) > {
114107 let filter = tracing_subscriber:: EnvFilter :: from_default_env ( ) ;
115- tracing_subscriber:: fmt ( ) . with_env_filter ( filter) . try_init ( ) . ok ( ) ;
108+ tracing_subscriber:: fmt ( )
109+ . with_env_filter ( filter)
110+ . try_init ( )
111+ . ok ( ) ;
116112 // set up static discovery for all addrs
117113 let discovery = StaticProvider :: new ( ) ;
118114 let endpoint = iroh:: Endpoint :: builder ( )
@@ -123,7 +119,7 @@ async fn connection_pool_errors() -> TestResult<()> {
123119 let client = EchoClient { pool } ;
124120 {
125121 let non_existing = SecretKey :: from_bytes ( & [ 0 ; 32 ] ) . public ( ) ;
126- let res = client. echo ( non_existing, b"Hello, world!" . to_vec ( ) ) . await ? ;
122+ let res = client. echo ( non_existing, b"Hello, world!" . to_vec ( ) ) . await ;
127123 // trying to connect to a non-existing id will fail with ConnectError
128124 // because we don't have any information about the node
129125 assert ! ( matches!( res, Err ( PoolConnectError :: ConnectError ( _) ) ) ) ;
@@ -140,9 +136,7 @@ async fn connection_pool_errors() -> TestResult<()> {
140136 } ) ;
141137 // trying to connect to an id for which we have info, but the other
142138 // end is not listening, will lead to a timeout.
143- let res = client
144- . echo ( non_listening, b"Hello, world!" . to_vec ( ) )
145- . await ?;
139+ let res = client. echo ( non_listening, b"Hello, world!" . to_vec ( ) ) . await ;
146140 assert ! ( matches!( res, Err ( PoolConnectError :: Timeout ) ) ) ;
147141 }
148142 Ok ( ( ) )
@@ -151,7 +145,10 @@ async fn connection_pool_errors() -> TestResult<()> {
151145#[ tokio:: test]
152146async fn connection_pool_smoke ( ) -> TestResult < ( ) > {
153147 let filter = tracing_subscriber:: EnvFilter :: from_default_env ( ) ;
154- tracing_subscriber:: fmt ( ) . with_env_filter ( filter) . try_init ( ) . ok ( ) ;
148+ tracing_subscriber:: fmt ( )
149+ . with_env_filter ( filter)
150+ . try_init ( )
151+ . ok ( ) ;
155152 let n = 32 ;
156153 let nodes = echo_servers ( n) . await ?;
157154 let ids = nodes
@@ -170,17 +167,17 @@ async fn connection_pool_smoke() -> TestResult<()> {
170167 let mut connection_ids = BTreeMap :: new ( ) ;
171168 let msg = b"Hello, world!" . to_vec ( ) ;
172169 for id in & ids {
173- let ( cid1, res) = client. echo ( * id, msg. clone ( ) ) . await ??? ;
170+ let ( cid1, res) = client. echo ( * id, msg. clone ( ) ) . await ??;
174171 assert_eq ! ( res, msg) ;
175- let ( cid2, res) = client. echo ( * id, msg. clone ( ) ) . await ??? ;
172+ let ( cid2, res) = client. echo ( * id, msg. clone ( ) ) . await ??;
176173 assert_eq ! ( res, msg) ;
177174 assert_eq ! ( cid1, cid2) ;
178175 connection_ids. insert ( id, cid1) ;
179176 }
180177 tokio:: time:: sleep ( Duration :: from_millis ( 1000 ) ) . await ;
181178 for id in & ids {
182179 let cid1 = * connection_ids. get ( id) . expect ( "Connection ID not found" ) ;
183- let ( cid2, res) = client. echo ( * id, msg. clone ( ) ) . await ??? ;
180+ let ( cid2, res) = client. echo ( * id, msg. clone ( ) ) . await ??;
184181 assert_eq ! ( res, msg) ;
185182 assert_ne ! ( cid1, cid2) ;
186183 }
@@ -192,7 +189,10 @@ async fn connection_pool_smoke() -> TestResult<()> {
192189#[ tokio:: test]
193190async fn connection_pool_idle ( ) -> TestResult < ( ) > {
194191 let filter = tracing_subscriber:: EnvFilter :: from_default_env ( ) ;
195- tracing_subscriber:: fmt ( ) . with_env_filter ( filter) . try_init ( ) . ok ( ) ;
192+ tracing_subscriber:: fmt ( )
193+ . with_env_filter ( filter)
194+ . try_init ( )
195+ . ok ( ) ;
196196 let n = 32 ;
197197 let nodes = echo_servers ( n) . await ?;
198198 let ids = nodes
@@ -218,7 +218,7 @@ async fn connection_pool_idle() -> TestResult<()> {
218218 let client = EchoClient { pool } ;
219219 let msg = b"Hello, world!" . to_vec ( ) ;
220220 for id in & ids {
221- let ( _, res) = client. echo ( * id, msg. clone ( ) ) . await ??? ;
221+ let ( _, res) = client. echo ( * id, msg. clone ( ) ) . await ??;
222222 assert_eq ! ( res, msg) ;
223223 }
224224 Ok ( ( ) )
0 commit comments