Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions antd-rust/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
})
}

Expand Down
6 changes: 6 additions & 0 deletions antd-rust/src/grpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
17 changes: 12 additions & 5 deletions antd-rust/src/grpc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}))
}
}
Expand Down Expand Up @@ -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]
Expand Down
19 changes: 18 additions & 1 deletion antd-rust/src/models.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
19 changes: 18 additions & 1 deletion antd-rust/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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]
Expand Down
Loading