use std::time::Duration; #[tokio::test] async fn relays_listing_should_return_array() { let client = reqwest::Client::builder() .timeout(Duration::from_secs(5)) .build() .expect("client"); let base = std::env::var("SDK_RELAY_HTTP").unwrap_or_else(|_| "http://localhost:8091".to_string()); let res = client.get(format!("{}/relays", base)).send().await.expect("/relays call"); assert!(res.status().is_success()); let json: serde_json::Value = res.json().await.expect("json"); assert!(json.get("relays").and_then(|v| v.as_array()).is_some(), "relays should be array"); } #[tokio::test] async fn sync_status_should_contain_sync_types() { let client = reqwest::Client::builder() .timeout(Duration::from_secs(5)) .build() .expect("client"); let base = std::env::var("SDK_RELAY_HTTP").unwrap_or_else(|_| "http://localhost:8091".to_string()); let res = client.get(format!("{}/sync/status", base)).send().await.expect("/sync/status call"); assert!(res.status().is_success()); let json: serde_json::Value = res.json().await.expect("json"); assert!(json.get("sync_types").and_then(|v| v.as_array()).is_some(), "sync_types should be array"); } #[tokio::test] async fn forcing_sync_should_return_sync_triggered() { let client = reqwest::Client::builder() .timeout(Duration::from_secs(5)) .build() .expect("client"); let base = std::env::var("SDK_RELAY_HTTP").unwrap_or_else(|_| "http://localhost:8091".to_string()); let body = serde_json::json!({"sync_types":["StateSync"]}); let res = client.post(format!("{}/sync/force", base)) .json(&body) .send().await.expect("/sync/force call"); assert!(res.status().is_success()); let json: serde_json::Value = res.json().await.expect("json"); let status = json.get("status").and_then(|v| v.as_str()).unwrap_or(""); assert_eq!(status, "sync_triggered"); }