Skip to content

Commit

Permalink
Reintroduce snapshots for invalid TXIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
upbqdn committed Dec 12, 2024
1 parent b54dd79 commit 7db6ff6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions zebra-rpc/src/methods/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ async fn test_rpc_response_data_for_network(network: &Network) {
settings.bind(|| insta::assert_json_snapshot!(format!("getrawtransaction_unknown_txid"), rsp));
mempool.expect_no_requests().await;

// `getrawtransaction` with an invalid TXID
let rsp = rpc
.get_raw_transaction("aBadC0de".to_owned(), Some(1))
.await;
settings.bind(|| insta::assert_json_snapshot!(format!("getrawtransaction_invalid_txid"), rsp));
mempool.expect_no_requests().await;

// `getaddresstxids`
let get_address_tx_ids = rpc
.get_address_tx_ids(GetAddressTxIdsRequest {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: zebra-rpc/src/methods/tests/snapshot.rs
expression: rsp
snapshot_kind: text
---
{
"Err": {
"code": -5,
"message": "Invalid string length"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: zebra-rpc/src/methods/tests/snapshot.rs
expression: rsp
snapshot_kind: text
---
{
"Err": {
"code": -5,
"message": "Invalid string length"
}
}
2 changes: 1 addition & 1 deletion zebra-rpc/src/methods/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ async fn rpc_getrawtransaction() {
let rpc_req = rpc.get_raw_transaction(tx.hash().encode_hex(), Some(0u8));

let (rsp, _) = futures::join!(rpc_req, mempool_req);
let get_tx = rsp.expect("We should have a ");
let get_tx = rsp.expect("we should have a `GetRawTransaction` struct");

if let GetRawTransaction::Raw(raw_tx) = get_tx {
assert_eq!(raw_tx.as_ref(), tx.zcash_serialize_to_vec().unwrap());
Expand Down

0 comments on commit 7db6ff6

Please sign in to comment.