use std::time::Duration; use tokio::time::timeout; use tokio_tungstenite::connect_async; #[tokio::test(flavor = "multi_thread")] async fn ws_connects_on_localhost_8090() { if std::env::var("RUN_WS_TEST").ok().as_deref() != Some("1") { // Test conditionnel: désactivé par défaut pour éviter les échecs en l'absence de serveur WS local return; } let url = std::env::var("SDK_RELAY_WS_URL").unwrap_or_else(|_| "ws://0.0.0.0:8090".to_string()); let connect_fut = connect_async(url); let res = timeout(Duration::from_secs(3), connect_fut).await; match res { Ok(Ok((_stream, _resp))) => { // Succès si la poignée de main WS passe } Ok(Err(e)) => panic!("Échec connexion WebSocket: {e}"), Err(_) => panic!("Timeout connexion WebSocket"), } }