Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
tests: add call getblockhash with list and nnamed params
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Nov 14, 2023
1 parent 34356a9 commit c8986b8
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use backtrace::Backtrace;

use jsonrpc::http::minreq_http;
use jsonrpc::{Client, Request};
use serde_json::json;
use serde_json::value::to_raw_value;

struct StdLogger;

Expand Down Expand Up @@ -113,6 +115,9 @@ fn main() {

run_test!(test_get_network_info);

run_test!(test_get_block_hash_list);
run_test!(test_get_block_hash_named);

// Print results
println!("");
println!("");
Expand Down Expand Up @@ -147,3 +152,39 @@ fn test_get_network_info(cl: &Client) {

let _ = cl.send_request(request).unwrap();
}

fn test_get_block_hash_list(cl: &Client) {
let param = json!([0]);
let raw_value = Some(to_raw_value(&param).unwrap());

let request = Request {
method: "getblockhash".into(),
params: raw_value.as_deref(),
id: serde_json::json!(2),
jsonrpc: Some("2.0"),
};

let resp = cl.send_request(request).unwrap();
assert_eq!(
resp.result.unwrap().to_string(),
"\"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206\""
);
}

fn test_get_block_hash_named(cl: &Client) {
let param = json!({ "height": 0 });
let raw_value = Some(to_raw_value(&param).unwrap());

let request = Request {
method: "getblockhash".into(),
params: raw_value.as_deref(),
id: serde_json::json!(2),
jsonrpc: Some("2.0"),
};

let resp = cl.send_request(request).unwrap();
assert_eq!(
resp.result.unwrap().to_string(),
"\"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206\""
);
}

0 comments on commit c8986b8

Please sign in to comment.