Skip to content

Commit

Permalink
Limit send transaction test to RPC queue length
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Jul 31, 2022
1 parent 1ce62d1 commit cfe3ebf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion zebra-rpc/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions zebrad/tests/common/lightwalletd/send_transaction_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//! already been seen in a block.
use std::{
cmp::min,
path::{Path, PathBuf},
sync::Arc,
};
Expand All @@ -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},
Expand All @@ -38,7 +41,6 @@ use crate::common::{
},
sync::perform_full_sync_starting_from,
};
use zebrad::components::mempool::downloads::MAX_INBOUND_CONCURRENCY;

/// The test entry point.
pub async fn run() -> Result<()> {
Expand Down Expand Up @@ -106,8 +108,8 @@ 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 `MAX_INBOUND_CONCURRENCY - 1`
transactions.truncate(MAX_INBOUND_CONCURRENCY - 1);
// 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(),
Expand Down

0 comments on commit cfe3ebf

Please sign in to comment.