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.
This commit is contained in:
Marek 2023-12-10 22:44:43 +01:00 committed by GitHub
parent 5dd33d7265
commit 9acdf0e512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -226,7 +226,7 @@ pub trait Rpc {
fn get_raw_transaction(
&self,
txid_hex: String,
verbose: u8,
verbose: Option<u8>,
) -> BoxFuture<Result<GetRawTransaction>>;
/// 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<u8>,
) -> BoxFuture<Result<GetRawTransaction>> {
let mut state = self.state.clone();
let mut mempool = self.mempool.clone();
let verbose = verbose.unwrap_or(0);
let verbose = verbose != 0;
async move {

View File

@ -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?;

View File

@ -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");

View File

@ -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<Block>, tx: Arc<Transaction>| {
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));