From 9acdf0e512fedd0a1bf939ec37a389d9bc68997b Mon Sep 17 00:00:00 2001 From: Marek Date: Sun, 10 Dec 2023 22:44:43 +0100 Subject: [PATCH] Make the `verbose` argument optional (#8076) The `verbose` argument of the `getrawtransaction` RPC is specified as optional in the documentation: https://zcash.github.io/rpc/getrawtransaction.html. --- zebra-rpc/src/methods.rs | 5 +++-- zebra-rpc/src/methods/tests/prop.rs | 4 ++-- zebra-rpc/src/methods/tests/snapshot.rs | 4 ++-- zebra-rpc/src/methods/tests/vectors.rs | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/zebra-rpc/src/methods.rs b/zebra-rpc/src/methods.rs index 179f30ff5..ea44310f3 100644 --- a/zebra-rpc/src/methods.rs +++ b/zebra-rpc/src/methods.rs @@ -226,7 +226,7 @@ pub trait Rpc { fn get_raw_transaction( &self, txid_hex: String, - verbose: u8, + verbose: Option, ) -> BoxFuture>; /// Returns the transaction ids made by the provided transparent addresses. @@ -945,10 +945,11 @@ where fn get_raw_transaction( &self, txid_hex: String, - verbose: u8, + verbose: Option, ) -> BoxFuture> { let mut state = self.state.clone(); let mut mempool = self.mempool.clone(); + let verbose = verbose.unwrap_or(0); let verbose = verbose != 0; async move { diff --git a/zebra-rpc/src/methods/tests/prop.rs b/zebra-rpc/src/methods/tests/prop.rs index 154f5d8c9..cf2cc7c1b 100644 --- a/zebra-rpc/src/methods/tests/prop.rs +++ b/zebra-rpc/src/methods/tests/prop.rs @@ -446,7 +446,7 @@ proptest! { NoChainTip, ); - let send_task = tokio::spawn(rpc.get_raw_transaction(non_hex_string, 0)); + let send_task = tokio::spawn(rpc.get_raw_transaction(non_hex_string, Some(0))); mempool.expect_no_requests().await?; state.expect_no_requests().await?; @@ -505,7 +505,7 @@ proptest! { NoChainTip, ); - let send_task = tokio::spawn(rpc.get_raw_transaction(hex::encode(random_bytes), 0)); + let send_task = tokio::spawn(rpc.get_raw_transaction(hex::encode(random_bytes), Some(0))); mempool.expect_no_requests().await?; state.expect_no_requests().await?; diff --git a/zebra-rpc/src/methods/tests/snapshot.rs b/zebra-rpc/src/methods/tests/snapshot.rs index 97fe46b6e..8b74f393e 100644 --- a/zebra-rpc/src/methods/tests/snapshot.rs +++ b/zebra-rpc/src/methods/tests/snapshot.rs @@ -252,7 +252,7 @@ async fn test_rpc_response_data_for_network(network: Network) { // make the api call let get_raw_transaction = - rpc.get_raw_transaction(first_block_first_transaction.hash().encode_hex(), 0u8); + rpc.get_raw_transaction(first_block_first_transaction.hash().encode_hex(), Some(0u8)); let (response, _) = futures::join!(get_raw_transaction, mempool_req); let get_raw_transaction = response.expect("We should have a GetRawTransaction struct"); @@ -269,7 +269,7 @@ async fn test_rpc_response_data_for_network(network: Network) { // make the api call let get_raw_transaction = - rpc.get_raw_transaction(first_block_first_transaction.hash().encode_hex(), 1u8); + rpc.get_raw_transaction(first_block_first_transaction.hash().encode_hex(), Some(1u8)); let (response, _) = futures::join!(get_raw_transaction, mempool_req); let get_raw_transaction = response.expect("We should have a GetRawTransaction struct"); diff --git a/zebra-rpc/src/methods/tests/vectors.rs b/zebra-rpc/src/methods/tests/vectors.rs index 408cf53af..63e53386d 100644 --- a/zebra-rpc/src/methods/tests/vectors.rs +++ b/zebra-rpc/src/methods/tests/vectors.rs @@ -423,7 +423,7 @@ async fn rpc_getrawtransaction() { conventional_fee: Amount::zero(), }])); }); - let get_tx_req = rpc.get_raw_transaction(tx.hash().encode_hex(), 0u8); + let get_tx_req = rpc.get_raw_transaction(tx.hash().encode_hex(), Some(0u8)); let (response, _) = futures::join!(get_tx_req, mempool_req); let get_tx = response.expect("We should have a GetRawTransaction struct"); if let GetRawTransaction::Raw(raw_tx) = get_tx { @@ -454,8 +454,8 @@ async fn rpc_getrawtransaction() { let run_state_test_case = |block_idx: usize, block: Arc, tx: Arc| { let read_state = read_state.clone(); let tx_hash = tx.hash(); - let get_tx_verbose_0_req = rpc.get_raw_transaction(tx_hash.encode_hex(), 0u8); - let get_tx_verbose_1_req = rpc.get_raw_transaction(tx_hash.encode_hex(), 1u8); + let get_tx_verbose_0_req = rpc.get_raw_transaction(tx_hash.encode_hex(), Some(0u8)); + let get_tx_verbose_1_req = rpc.get_raw_transaction(tx_hash.encode_hex(), Some(1u8)); async move { let (response, _) = futures::join!(get_tx_verbose_0_req, make_mempool_req(tx_hash));