fix(test): truncate the number of transactions in send transaction test (#4848)
* truncate the number of transactions in send transaction test * Limit send transaction test to RPC queue length Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
parent
e9c9ea91bc
commit
a6f15e84a8
|
@ -39,7 +39,7 @@ mod tests;
|
|||
const NUMBER_OF_BLOCKS_TO_EXPIRE: i64 = 5;
|
||||
|
||||
/// Size of the queue and channel.
|
||||
const CHANNEL_AND_QUEUE_CAPACITY: usize = 20;
|
||||
pub const CHANNEL_AND_QUEUE_CAPACITY: usize = 20;
|
||||
|
||||
/// The height to use in spacing calculation if we don't have a chain tip.
|
||||
const NO_CHAIN_TIP_HEIGHT: Height = Height(1);
|
||||
|
|
|
@ -94,7 +94,7 @@ pub(crate) const TRANSACTION_VERIFY_TIMEOUT: Duration = BLOCK_VERIFY_TIMEOUT;
|
|||
/// Since Zebra keeps an `inv` index, inbound downloads for malicious transactions
|
||||
/// will be directed to the malicious node that originally gossiped the hash.
|
||||
/// Therefore, this attack can be carried out by a single malicious node.
|
||||
pub(crate) const MAX_INBOUND_CONCURRENCY: usize = 10;
|
||||
pub const MAX_INBOUND_CONCURRENCY: usize = 10;
|
||||
|
||||
/// Errors that can occur while downloading and verifying a transaction.
|
||||
#[derive(Error, Debug)]
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
//! already been seen in a block.
|
||||
|
||||
use std::{
|
||||
cmp::min,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
|
@ -26,7 +27,9 @@ use zebra_chain::{
|
|||
block, chain_tip::ChainTip, parameters::Network, serialization::ZcashSerialize,
|
||||
transaction::Transaction,
|
||||
};
|
||||
use zebra_rpc::queue::CHANNEL_AND_QUEUE_CAPACITY;
|
||||
use zebra_state::HashOrHeight;
|
||||
use zebrad::components::mempool::downloads::MAX_INBOUND_CONCURRENCY;
|
||||
|
||||
use crate::common::{
|
||||
cached_state::{load_tip_height_from_state_directory, start_state_service_with_cache_dir},
|
||||
|
@ -74,7 +77,7 @@ pub async fn run() -> Result<()> {
|
|||
"running gRPC send transaction test using lightwalletd & zebrad",
|
||||
);
|
||||
|
||||
let transactions =
|
||||
let mut transactions =
|
||||
load_transactions_from_a_future_block(network, zebrad_state_path.clone()).await?;
|
||||
|
||||
tracing::info!(
|
||||
|
@ -105,6 +108,9 @@ pub async fn run() -> Result<()> {
|
|||
|
||||
let mut rpc_client = connect_to_lightwalletd(lightwalletd_rpc_port).await?;
|
||||
|
||||
// To avoid filling the mempool queue, limit the transactions to be sent to the RPC and mempool queue limits
|
||||
transactions.truncate(min(CHANNEL_AND_QUEUE_CAPACITY, MAX_INBOUND_CONCURRENCY) - 1);
|
||||
|
||||
tracing::info!(
|
||||
transaction_count = ?transactions.len(),
|
||||
"connected gRPC client to lightwalletd, sending transactions...",
|
||||
|
|
Loading…
Reference in New Issue