From 55bcd27deafadd43df295029ba1d701491e9a4b3 Mon Sep 17 00:00:00 2001 From: Arya Date: Tue, 26 Nov 2024 17:23:08 -0500 Subject: [PATCH] avoids panic when a future block has only a coinbase transaction --- .../lightwalletd/send_transaction_test.rs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/zebrad/tests/common/lightwalletd/send_transaction_test.rs b/zebrad/tests/common/lightwalletd/send_transaction_test.rs index 2de3dc43bf1..ca4bc4f9677 100644 --- a/zebrad/tests/common/lightwalletd/send_transaction_test.rs +++ b/zebrad/tests/common/lightwalletd/send_transaction_test.rs @@ -186,13 +186,19 @@ pub async fn run() -> Result<()> { let mut counter = 0; for block in blocks { - let (zebrad_child, has_shielded_elements, count) = - send_transactions_from_block(zebrad, &mut rpc_client, &zebrad_rpc_client, block) - .await?; + let (zebrad_child, has_shielded_elements, count) = send_transactions_from_block( + zebrad, + &mut rpc_client, + &zebrad_rpc_client, + block.clone(), + ) + .await?; zebrad = zebrad_child; has_tx_with_shielded_elements |= has_shielded_elements; counter += count; + + zebrad_rpc_client.submit_block(block).await?; } // GetMempoolTx: make sure at least one of the transactions were inserted into the mempool. @@ -231,6 +237,10 @@ async fn send_transactions_from_block( .filter(|tx| !tx.is_coinbase()) .collect(); + if !transactions.is_empty() { + return Ok((zebrad, false, 0)); + } + let transaction_hashes: Vec = transactions.iter().map(|tx| tx.hash()).collect(); @@ -241,7 +251,7 @@ async fn send_transactions_from_block( ); let mut has_tx_with_shielded_elements = false; - for transaction in transactions { + for &transaction in &transactions { let transaction_hash = transaction.hash(); // See @@ -329,8 +339,6 @@ async fn send_transactions_from_block( _counter += 1; } - zebrad_rpc_client.submit_block(block).await?; - Ok((zebrad, has_tx_with_shielded_elements, counter)) }