26 lines
737 B
Rust
26 lines
737 B
Rust
use circle_ws_lib::{spawn_circle_server, ServerConfig};
|
|
use std::time::Duration;
|
|
use tokio_tungstenite::connect_async;
|
|
use url::Url;
|
|
|
|
#[tokio::test]
|
|
async fn test_server_connection() {
|
|
let config = ServerConfig::new(
|
|
"127.0.0.1".to_string(),
|
|
9001,
|
|
"redis://127.0.0.1:6379".to_string(),
|
|
);
|
|
|
|
let (server_handle, _server_stop_handle) = spawn_circle_server(config).unwrap();
|
|
|
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
|
|
|
let url_str = "ws://127.0.0.1:9001/test_pub_key";
|
|
let url = Url::parse(url_str).unwrap();
|
|
let (ws_stream, _) = connect_async(url).await.expect("Failed to connect");
|
|
|
|
println!("WebSocket connection successful: {:?}", ws_stream);
|
|
|
|
server_handle.abort();
|
|
}
|