Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
tendermint-rs: /health RPC endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-iqlusion committed Apr 22, 2019
1 parent 2aa623a commit 469daee
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions tendermint-rs/src/rpc/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod block;
pub mod blockchain;
pub mod commit;
pub mod genesis;
pub mod health;
pub mod net_info;
pub mod status;
pub mod validators;
22 changes: 22 additions & 0 deletions tendermint-rs/src/rpc/endpoint/health.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! `/health` endpoint JSONRPC wrapper

use crate::rpc;
use serde::{Deserialize, Serialize};

/// Perform a basic healthceck of the backend
#[derive(Default)]
pub struct Request;

impl rpc::Request for Request {
type Response = Response;

fn path(&self) -> rpc::request::Path {
"/health".parse().unwrap()
}
}

/// Healthcheck responses
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {}

impl rpc::Response for Response {}
5 changes: 5 additions & 0 deletions tendermint-rs/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ mod endpoints {
assert_eq!(consensus_params.block_size.max_bytes, 150000);
}

#[test]
fn health() {
endpoint::health::Response::from_json(&read_json_fixture("health")).unwrap();
}

#[test]
fn net_info() {
let response =
Expand Down
5 changes: 5 additions & 0 deletions tendermint-rs/tests/support/rpc/health.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"jsonrpc": "2.0",
"id": "",
"result": {}
}

0 comments on commit 469daee

Please sign in to comment.