add `z_get_treestate` snapshot test (#4401)
This commit is contained in:
parent
4c76ae862b
commit
191b1c02a2
|
|
@ -16,9 +16,6 @@ use zebra_test::mock_service::MockService;
|
||||||
use super::super::*;
|
use super::super::*;
|
||||||
|
|
||||||
/// Snapshot test for RPC methods responses.
|
/// Snapshot test for RPC methods responses.
|
||||||
///
|
|
||||||
/// TODO:
|
|
||||||
/// - Add a `z_gettreestate` test when #3990 is merged.
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_rpc_response_data() {
|
async fn test_rpc_response_data() {
|
||||||
zebra_test::init();
|
zebra_test::init();
|
||||||
|
|
@ -119,6 +116,13 @@ async fn test_rpc_response_data_for_network(network: Network) {
|
||||||
|
|
||||||
snapshot_rpc_getrawmempool(get_raw_mempool, &settings);
|
snapshot_rpc_getrawmempool(get_raw_mempool, &settings);
|
||||||
|
|
||||||
|
// `z_gettreestate`
|
||||||
|
let tree_state = rpc
|
||||||
|
.z_get_treestate(BLOCK_HEIGHT.to_string())
|
||||||
|
.await
|
||||||
|
.expect("We should have a GetTreestate struct");
|
||||||
|
snapshot_rpc_z_gettreestate(tree_state, &settings);
|
||||||
|
|
||||||
// `getrawtransaction`
|
// `getrawtransaction`
|
||||||
//
|
//
|
||||||
// - similar to `getrawmempool` described above, a mempool request will be made to get the requested
|
// - similar to `getrawmempool` described above, a mempool request will be made to get the requested
|
||||||
|
|
@ -217,6 +221,11 @@ fn snapshot_rpc_getrawmempool(raw_mempool: Vec<String>, settings: &insta::Settin
|
||||||
settings.bind(|| insta::assert_json_snapshot!("get_raw_mempool", raw_mempool));
|
settings.bind(|| insta::assert_json_snapshot!("get_raw_mempool", raw_mempool));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Snapshot `z_gettreestate` response, using `cargo insta` and JSON serialization.
|
||||||
|
fn snapshot_rpc_z_gettreestate(tree_state: GetTreestate, settings: &insta::Settings) {
|
||||||
|
settings.bind(|| insta::assert_json_snapshot!("z_get_treestate", tree_state));
|
||||||
|
}
|
||||||
|
|
||||||
/// Snapshot `getrawtransaction` response, using `cargo insta` and JSON serialization.
|
/// Snapshot `getrawtransaction` response, using `cargo insta` and JSON serialization.
|
||||||
fn snapshot_rpc_getrawtransaction(raw_transaction: GetRawTransaction, settings: &insta::Settings) {
|
fn snapshot_rpc_getrawtransaction(raw_transaction: GetRawTransaction, settings: &insta::Settings) {
|
||||||
settings.bind(|| insta::assert_json_snapshot!("get_raw_transaction", raw_transaction));
|
settings.bind(|| insta::assert_json_snapshot!("get_raw_transaction", raw_transaction));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: zebra-rpc/src/methods/tests/snapshot.rs
|
||||||
|
assertion_line: 226
|
||||||
|
expression: tree_state
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"hash": "0007bc227e1c57a4a70e237cad00e7b7ce565155ab49166bc57397a26d339283",
|
||||||
|
"height": 1,
|
||||||
|
"time": 1477671596
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
source: zebra-rpc/src/methods/tests/snapshot.rs
|
||||||
|
assertion_line: 226
|
||||||
|
expression: tree_state
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"hash": "025579869bcf52a989337342f5f57a84f3a28b968f7d6a8307902b065a668d23",
|
||||||
|
"height": 1,
|
||||||
|
"time": 1477674473
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue