From 7e3ddd49dcb9f14affa019126553218fee1454e0 Mon Sep 17 00:00:00 2001 From: Sonee Date: Wed, 25 Feb 2026 09:18:09 +0000 Subject: [PATCH 1/2] Decouple `wait_for_readiness` from CLI parsing && fix minor typos Removed the direct CliArgs::parse() call from `wait_for_readiness` and instead passes `timeout` as a parameter from `main`. Previously, `wait_for_readiness` re-parsed CLI arguments internally to access the `timeout` value. This created tight coupling between the function and the CLI layer. Although this worked for the current binary use case, it introduced several architectural drawbacks: - The function depended directly on CLI parsing. - It could not be reused programmatically without CLI context. - CLI parsing was executed twice. `wait_for_readiness` is business logic and should not depend on how configuration is obtained. What Changed: - Added `timeout`: Duration parameter to `wait_for_readiness` - Removed internal `CliArgs::parse()` call - Passed `Duration::from_secs(args.timeout)` from `main` - Updated timeout error message to use `timeout.as_secs()` --- crates/rpc-tester-cli/src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/rpc-tester-cli/src/main.rs b/crates/rpc-tester-cli/src/main.rs index 194e07f..574d7f8 100644 --- a/crates/rpc-tester-cli/src/main.rs +++ b/crates/rpc-tester-cli/src/main.rs @@ -35,7 +35,7 @@ pub struct CliArgs { #[arg(long, value_name = "TRACING", default_value = "false")] pub use_tracing: bool, - /// Whether to query every transacion from a block or just the first. + /// Whether to query every transaction from a block or just the first. #[arg(long, value_name = "ALL_TXES", default_value = "false")] pub use_all_txes: bool, @@ -69,7 +69,9 @@ async fn main() -> eyre::Result<()> { .network::() .on_http(args.rpc2); - let block_range = wait_for_readiness(&rpc1, &rpc2, args.num_blocks).await?; + let timeout = Duration::from_secs(args.timeout); + + let block_range = wait_for_readiness(&rpc1, &rpc2, args.num_blocks, timeout).await?; RpcTester::builder(rpc1, rpc2) .with_tracing(args.use_tracing) @@ -87,17 +89,16 @@ pub async fn wait_for_readiness>( rpc1: &P, rpc2: &P, block_size_range: u64, + timeout: Duration, ) -> eyre::Result> { - let args = CliArgs::parse(); let start_time = Instant::now(); - let timeout = Duration::from_secs(args.timeout); // Waits until it's done syncing while let SyncStatus::Info(sync_info) = rpc1.syncing().await? { if start_time.elapsed() > timeout { return Err(eyre::eyre!( "Timeout waiting for rpc1 to sync after {} seconds", - args.timeout + timeout.as_secs() )); } info!(?sync_info, "rpc1 still syncing"); From 96f7c7a5fe962a56c3a542737ec4086d1b16a168 Mon Sep 17 00:00:00 2001 From: Sonee Date: Wed, 25 Feb 2026 09:18:58 +0000 Subject: [PATCH 2/2] fix minor typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 505bd40..f8276ae 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Options: --num-blocks Number of blocks to test from the tip [default: 32] --use-reth Whether to query reth namespace --use-tracing Whether to query tracing methods - --use-all-txes Whether to query every transacion from a block or just the first + --use-all-txes Whether to query every transaction from a block or just the first --rate-limit Maximum requests per second (rate limit) --timeout Maximum time to wait for syncing in seconds [default: 300] -h, --help Print help