cuprate_test_utils::rpc::data::json

Constant GET_BLOCK_HASH_REQUEST

Source
pub const GET_BLOCK_HASH_REQUEST: &str = r#"{
  "jsonrpc": "2.0",
  "id": "0",
  "method": "get_block",
  "params": {
    "hash": "86d421322b700166dde2d7eba1cc8600925ef640abf6c0a2cc8ce0d6dd90abfd"
  }
}"#;
Expand description

Documentation, response.

This is the same as GET_BLOCK_REQUEST and GET_BLOCK_RESPONSE but it uses the hash parameter.

use cuprate_test_utils::rpc::data::json::*;
use serde_json::{to_value, Value};

let value = serde_json::from_str::<Value>(&GET_BLOCK_HASH_REQUEST).unwrap();
let Value::Object(map) = value else {
    panic!();
};

assert_eq!(map.get("jsonrpc").unwrap(), "2.0");
map.get("id").unwrap();

if map.get("method").is_some() {
    return;
}

if map.get("result").is_none() {
    map.get("error").unwrap();
}