diff --git a/antd-rust/src/client.rs b/antd-rust/src/client.rs index 3c021ff..1cb28ee 100644 --- a/antd-rust/src/client.rs +++ b/antd-rust/src/client.rs @@ -162,6 +162,15 @@ impl Client { Ok(HealthStatus { ok: Self::str_field(&j, "status") == "ok", network: Self::str_field(&j, "network"), + version: Self::str_field(&j, "version"), + evm_network: Self::str_field(&j, "evm_network"), + uptime_seconds: j + .get("uptime_seconds") + .and_then(|v| v.as_u64()) + .unwrap_or(0), + build_commit: Self::str_field(&j, "build_commit"), + payment_token_address: Self::str_field(&j, "payment_token_address"), + payment_vault_address: Self::str_field(&j, "payment_vault_address"), }) } diff --git a/antd-rust/src/grpc_client.rs b/antd-rust/src/grpc_client.rs index 6f93710..b56d7a0 100644 --- a/antd-rust/src/grpc_client.rs +++ b/antd-rust/src/grpc_client.rs @@ -81,6 +81,12 @@ impl GrpcClient { Ok(HealthStatus { ok: resp.status == "ok", network: resp.network, + version: resp.version, + evm_network: resp.evm_network, + uptime_seconds: resp.uptime_seconds, + build_commit: resp.build_commit, + payment_token_address: resp.payment_token_address, + payment_vault_address: resp.payment_vault_address, }) } diff --git a/antd-rust/src/grpc_tests.rs b/antd-rust/src/grpc_tests.rs index 1ed5892..ff2d031 100644 --- a/antd-rust/src/grpc_tests.rs +++ b/antd-rust/src/grpc_tests.rs @@ -20,11 +20,12 @@ impl v1::health_service_server::HealthService for MockHealthService { Ok(Response::new(v1::HealthCheckResponse { status: "ok".to_string(), network: "local".to_string(), - // Diagnostic fields added in 0.4.0 — left as defaults here - // because antd-rust's HealthStatus model has not yet been - // extended (tracked in issue #37). The mock just needs to - // satisfy the wire type. - ..Default::default() + version: "0.4.0".to_string(), + evm_network: "local".to_string(), + uptime_seconds: 42, + build_commit: "abcdef123456".to_string(), + payment_token_address: "0xtoken".to_string(), + payment_vault_address: "0xvault".to_string(), })) } } @@ -275,6 +276,12 @@ async fn test_grpc_health() { let health = client.health().await.unwrap(); assert!(health.ok); assert_eq!(health.network, "local"); + assert_eq!(health.version, "0.4.0"); + assert_eq!(health.evm_network, "local"); + assert_eq!(health.uptime_seconds, 42); + assert_eq!(health.build_commit, "abcdef123456"); + assert_eq!(health.payment_token_address, "0xtoken"); + assert_eq!(health.payment_vault_address, "0xvault"); } #[tokio::test] diff --git a/antd-rust/src/models.rs b/antd-rust/src/models.rs index a688879..f72d680 100644 --- a/antd-rust/src/models.rs +++ b/antd-rust/src/models.rs @@ -1,10 +1,27 @@ use serde::{Deserialize, Serialize}; /// Result of a health check against the antd daemon. -#[derive(Debug, Clone, Serialize, Deserialize)] +/// +/// The diagnostic fields (`version`, `evm_network`, `uptime_seconds`, +/// `build_commit`, `payment_token_address`, `payment_vault_address`) were +/// added in antd 0.4.0. They default to empty / 0 via `#[serde(default)]`, +/// so deserialization tolerates pre-0.4.0 daemon responses. +#[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct HealthStatus { pub ok: bool, pub network: String, + #[serde(default)] + pub version: String, + #[serde(default)] + pub evm_network: String, + #[serde(default)] + pub uptime_seconds: u64, + #[serde(default)] + pub build_commit: String, + #[serde(default)] + pub payment_token_address: String, + #[serde(default)] + pub payment_vault_address: String, } /// Result of a put/create operation containing cost and address. diff --git a/antd-rust/src/tests.rs b/antd-rust/src/tests.rs index be8f614..3de9b02 100644 --- a/antd-rust/src/tests.rs +++ b/antd-rust/src/tests.rs @@ -15,7 +15,18 @@ fn mock_health(server: &mut ServerGuard) -> Mock { .mock("GET", "/health") .with_status(200) .with_header("content-type", "application/json") - .with_body(r#"{"status":"ok","network":"local"}"#) + .with_body( + r#"{ + "status":"ok", + "network":"local", + "version":"0.4.0", + "evm_network":"local", + "uptime_seconds":42, + "build_commit":"abcdef123456", + "payment_token_address":"0xtoken", + "payment_vault_address":"0xvault" + }"#, + ) .create() } @@ -201,6 +212,12 @@ async fn test_health() { let health = client.health().await.unwrap(); assert!(health.ok); assert_eq!(health.network, "local"); + assert_eq!(health.version, "0.4.0"); + assert_eq!(health.evm_network, "local"); + assert_eq!(health.uptime_seconds, 42); + assert_eq!(health.build_commit, "abcdef123456"); + assert_eq!(health.payment_token_address, "0xtoken"); + assert_eq!(health.payment_vault_address, "0xvault"); } #[tokio::test]