cuprate_test_utils::rpc::data::json

Constant GET_LAST_BLOCK_HEADER_RESPONSE

Source
pub const GET_LAST_BLOCK_HEADER_RESPONSE: &str = r#"{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "block_size": 200419,
      "block_weight": 200419,
      "cumulative_difficulty": 366125734645190820,
      "cumulative_difficulty_top64": 0,
      "depth": 0,
      "difficulty": 282052561854,
      "difficulty_top64": 0,
      "hash": "57238217820195ac4c08637a144a885491da167899cf1d20e8e7ce0ae0a3434e",
      "height": 3195020,
      "long_term_weight": 200419,
      "major_version": 16,
      "miner_tx_hash": "7a42667237d4f79891bb407c49c712a9299fb87fce799833a7b633a3a9377dbd",
      "minor_version": 16,
      "nonce": 1885649739,
      "num_txes": 37,
      "orphan_status": false,
      "pow_hash": "",
      "prev_hash": "22c72248ae9c5a2863c94735d710a3525c499f70707d1c2f395169bc5c8a0da3",
      "reward": 615702960000,
      "timestamp": 1721245548,
      "wide_cumulative_difficulty": "0x514bd6a74a7d0a4",
      "wide_difficulty": "0x41aba48bbe"
    },
    "credits": 0,
    "status": "OK",
    "top_hash": "",
    "untrusted": false
  }
}"#;
Expand description

Documentation, request.

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

let value = serde_json::from_str::<Value>(&GET_LAST_BLOCK_HEADER_RESPONSE).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();
}