Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): truncate the number of transactions in send transaction test #4848

Merged
merged 2 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion zebrad/src/components/mempool/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 7 additions & 1 deletion 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 Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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...",
Expand Down