@@ -173,7 +173,7 @@ fn test_weak_mode_appends_no_proxy() {
173173}
174174
175175// Simple server start function - we know the ports we're setting
176- fn start_server ( http_port : u16 , https_port : u16 ) -> Result < std:: process:: Child , String > {
176+ async fn start_server ( http_port : u16 , https_port : u16 ) -> Result < std:: process:: Child , String > {
177177 let httpjail_path: & str = env ! ( "CARGO_BIN_EXE_httpjail" ) ;
178178
179179 let mut cmd = Command :: new ( httpjail_path) ;
@@ -192,7 +192,7 @@ fn start_server(http_port: u16, https_port: u16) -> Result<std::process::Child,
192192 . map_err ( |e| format ! ( "Failed to start server: {}" , e) ) ?;
193193
194194 // Wait for the server to start listening
195- if !common:: wait_for_server ( http_port, Duration :: from_secs ( 5 ) ) {
195+ if !common:: wait_for_server ( http_port, Duration :: from_secs ( 5 ) ) . await {
196196 return Err ( format ! ( "Server failed to start on port {}" , http_port) ) ;
197197 }
198198
@@ -250,13 +250,15 @@ fn verify_bind_address(port: u16, expected_ip: &str) -> bool {
250250 std:: net:: TcpStream :: connect ( format ! ( "{}:{}" , expected_ip, port) ) . is_ok ( )
251251}
252252
253- #[ test]
254- fn test_server_mode ( ) {
253+ #[ tokio :: test]
254+ async fn test_server_mode ( ) {
255255 // Test server mode with specific ports
256256 let http_port = 19876 ;
257257 let https_port = 19877 ;
258258
259- let mut server = start_server ( http_port, https_port) . expect ( "Failed to start server" ) ;
259+ let mut server = start_server ( http_port, https_port)
260+ . await
261+ . expect ( "Failed to start server" ) ;
260262
261263 // Test HTTP proxy works
262264 match test_curl_through_proxy ( http_port, https_port) {
@@ -278,7 +280,7 @@ fn test_server_mode() {
278280}
279281
280282// Helper to start server with custom bind config
281- fn start_server_with_bind ( http_bind : & str , https_bind : & str ) -> ( std:: process:: Child , u16 ) {
283+ async fn start_server_with_bind ( http_bind : & str , https_bind : & str ) -> ( std:: process:: Child , u16 ) {
282284 let httpjail_path: & str = env ! ( "CARGO_BIN_EXE_httpjail" ) ;
283285
284286 let mut child = Command :: new ( httpjail_path)
@@ -306,61 +308,61 @@ fn start_server_with_bind(http_bind: &str, https_bind: &str) -> (std::process::C
306308 } ;
307309
308310 // Wait for server to bind
309- if !common:: wait_for_server ( expected_port, Duration :: from_secs ( 3 ) ) {
311+ if !common:: wait_for_server ( expected_port, Duration :: from_secs ( 3 ) ) . await {
310312 child. kill ( ) . ok ( ) ;
311313 panic ! ( "Server failed to bind to port {}" , expected_port) ;
312314 }
313315
314316 ( child, expected_port)
315317}
316318
317- #[ test]
319+ #[ tokio :: test]
318320#[ serial]
319- fn test_server_bind_defaults ( ) {
320- let ( mut server, port) = start_server_with_bind ( "" , "" ) ;
321+ async fn test_server_bind_defaults ( ) {
322+ let ( mut server, port) = start_server_with_bind ( "" , "" ) . await ;
321323 assert_eq ! ( port, 8080 , "Server should default to port 8080" ) ;
322324 server. kill ( ) . ok ( ) ;
323325}
324326
325- #[ test]
327+ #[ tokio :: test]
326328#[ serial]
327- fn test_server_bind_port_only ( ) {
329+ async fn test_server_bind_port_only ( ) {
328330 // Port-only should bind to all interfaces (0.0.0.0)
329- let ( mut server, port) = start_server_with_bind ( "19882" , "19883" ) ;
331+ let ( mut server, port) = start_server_with_bind ( "19882" , "19883" ) . await ;
330332 assert_eq ! (
331333 port, 19882 ,
332334 "Server should bind to specified port on all interfaces"
333335 ) ;
334336 server. kill ( ) . ok ( ) ;
335337}
336338
337- #[ test]
339+ #[ tokio :: test]
338340#[ serial]
339- fn test_server_bind_colon_prefix_port ( ) {
341+ async fn test_server_bind_colon_prefix_port ( ) {
340342 // :port (Go-style) should bind to all interfaces (0.0.0.0)
341- let ( mut server, port) = start_server_with_bind ( ":19892" , ":19893" ) ;
343+ let ( mut server, port) = start_server_with_bind ( ":19892" , ":19893" ) . await ;
342344 assert_eq ! (
343345 port, 19892 ,
344346 "Server should bind to specified port on all interfaces with :port format"
345347 ) ;
346348 server. kill ( ) . ok ( ) ;
347349}
348350
349- #[ test]
351+ #[ tokio :: test]
350352#[ serial]
351- fn test_server_bind_all_interfaces ( ) {
352- let ( mut server, port) = start_server_with_bind ( "0.0.0.0:19884" , "0.0.0.0:19885" ) ;
353+ async fn test_server_bind_all_interfaces ( ) {
354+ let ( mut server, port) = start_server_with_bind ( "0.0.0.0:19884" , "0.0.0.0:19885" ) . await ;
353355 assert_eq ! (
354356 port, 19884 ,
355357 "Server should bind to specified port on 0.0.0.0"
356358 ) ;
357359 server. kill ( ) . ok ( ) ;
358360}
359361
360- #[ test]
362+ #[ tokio :: test]
361363#[ serial]
362- fn test_server_bind_ip_without_port ( ) {
363- let ( mut server, port) = start_server_with_bind ( "127.0.0.1" , "127.0.0.1" ) ;
364+ async fn test_server_bind_ip_without_port ( ) {
365+ let ( mut server, port) = start_server_with_bind ( "127.0.0.1" , "127.0.0.1" ) . await ;
364366 assert_eq ! (
365367 port, 8080 ,
366368 "Server should use default port 8080 when only IP specified"
0 commit comments