From 33fd1a015f5ef68b310b55c7ce71dc791b8f6641 Mon Sep 17 00:00:00 2001 From: Gulshan Yadav Date: Mon, 2 Feb 2026 02:31:14 +0530 Subject: [PATCH] fix: faucet health check uses JSON-RPC instead of REST The synord RPC server is JSON-RPC only, not REST. Changed health check from GET /health to POST with synor_getInfo method. --- apps/faucet/src/main.rs | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/apps/faucet/src/main.rs b/apps/faucet/src/main.rs index 7e8a222..dd7b023 100644 --- a/apps/faucet/src/main.rs +++ b/apps/faucet/src/main.rs @@ -600,16 +600,45 @@ async fn faucet( } } -/// Check if the RPC node is reachable. +/// Check if the RPC node is reachable via JSON-RPC. async fn check_rpc_connection(state: &FaucetState) -> bool { - let url = format!("{}/health", state.config.rpc_url); - state + #[derive(Serialize)] + struct RpcRequest { + jsonrpc: &'static str, + method: &'static str, + params: Vec<()>, + id: u64, + } + + #[derive(Deserialize)] + struct RpcResponse { + result: Option, + #[allow(dead_code)] + error: Option, + } + + let request = RpcRequest { + jsonrpc: "2.0", + method: "synor_getInfo", + params: vec![], + id: 1, + }; + + let response = match state .http_client - .get(&url) + .post(&state.config.rpc_url) + .json(&request) .send() .await - .map(|r| r.status().is_success()) - .unwrap_or(false) + { + Ok(r) if r.status().is_success() => r, + _ => return false, + }; + + match response.json::().await { + Ok(resp) => resp.result.is_some(), + Err(_) => false, + } } /// Validate Synor address format.