diff --git a/Cargo.lock b/Cargo.lock index 3e96b6a..40394be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3319,7 +3319,7 @@ dependencies = [ [[package]] name = "tests-monero-serai" -version = "0.1.0" +version = "0.0.0" dependencies = [ "futures", "hex", @@ -3333,7 +3333,7 @@ dependencies = [ [[package]] name = "tests-pow" -version = "0.1.0" +version = "0.0.0" dependencies = [ "cuprate-consensus-rules", "cuprate-cryptonight", diff --git a/tests/monero-serai/Cargo.toml b/tests/monero-serai/Cargo.toml index d10f8c7..0088e32 100644 --- a/tests/monero-serai/Cargo.toml +++ b/tests/monero-serai/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tests-monero-serai" -version = "0.1.0" +version = "0.0.0" edition = "2021" [dependencies] diff --git a/tests/monero-serai/src/main.rs b/tests/monero-serai/src/main.rs index 2327b84..9dd8590 100644 --- a/tests/monero-serai/src/main.rs +++ b/tests/monero-serai/src/main.rs @@ -13,14 +13,29 @@ async fn main() { let now = Instant::now(); let rpc_url = if let Ok(url) = std::env::var("RPC_URL") { + println!("RPC_URL (found): {url}"); url } else { - "http://127.0.0.1:18081".to_string() + let rpc_url = "http://127.0.0.1:18081".to_string(); + println!("RPC_URL (off, using default): {rpc_url}"); + rpc_url }; - println!("rpc_url: {rpc_url}"); + if std::env::var("VERBOSE").is_ok() { + println!("VERBOSE: true"); + } else { + println!("VERBOSE: false"); + } - let client = rpc::RpcClient::new(rpc_url).await; - let top_height = client.top_height; + let mut client = rpc::RpcClient::new(rpc_url).await; + + let top_height = if let Ok(Ok(h)) = std::env::var("TOP_HEIGHT").map(|s| s.parse()) { + client.top_height = h; + println!("TOP_HEIGHT (found): {h}"); + h + } else { + println!("TOP_HEIGHT (off, using latest): {}", client.top_height); + client.top_height + }; let ranges = (0..top_height) .collect::>() @@ -28,11 +43,17 @@ async fn main() { .map(<[usize]>::to_vec) .collect::>>(); - println!("ranges: "); + println!("ranges: ["); for range in &ranges { - println!("[{}..{}]", range.first().unwrap(), range.last().unwrap()); + println!( + " ({}..{}),", + range.first().unwrap(), + range.last().unwrap() + ); } + println!("]\n"); + let iter = ranges.into_iter().map(move |range| { let c = client.clone(); async move { diff --git a/tests/monero-serai/src/rpc.rs b/tests/monero-serai/src/rpc.rs index 49e7dc2..2455989 100644 --- a/tests/monero-serai/src/rpc.rs +++ b/tests/monero-serai/src/rpc.rs @@ -81,7 +81,6 @@ impl RpcClient { .block_header .height; - println!("top_height: {top_height}"); assert!(top_height > 3301441, "node is behind"); Self { @@ -258,6 +257,11 @@ impl RpcClient { let progress = TESTED_BLOCK_COUNT.fetch_add(1, Ordering::Release) + 1; let tx_count = TESTED_TX_COUNT.fetch_add(num_txes, Ordering::Release) + 1; + + if std::env::var("VERBOSE").is_err() && progress % 1000 != 0 { + return; + } + let percent = (progress as f64 / top_height as f64) * 100.0; println!( diff --git a/tests/pow/Cargo.toml b/tests/pow/Cargo.toml index 06a5743..74a5f3a 100644 --- a/tests/pow/Cargo.toml +++ b/tests/pow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tests-pow" -version = "0.1.0" +version = "0.0.0" edition = "2021" [dependencies] diff --git a/tests/pow/src/main.rs b/tests/pow/src/main.rs index 9ac4d31..22186a0 100644 --- a/tests/pow/src/main.rs +++ b/tests/pow/src/main.rs @@ -12,14 +12,31 @@ async fn main() { let now = Instant::now(); let rpc_url = if let Ok(url) = std::env::var("RPC_URL") { + println!("RPC_URL (found): {url}"); url } else { - "http://127.0.0.1:18081".to_string() + let rpc_url = "http://127.0.0.1:18081".to_string(); + println!("RPC_URL (off, using default): {rpc_url}"); + rpc_url }; - println!("rpc_url: {rpc_url}"); + if std::env::var("VERBOSE").is_ok() { + println!("VERBOSE: true"); + } else { + println!("VERBOSE: false"); + } - let client = rpc::RpcClient::new(rpc_url).await; - let top_height = client.top_height; + let mut client = rpc::RpcClient::new(rpc_url).await; + + let top_height = if let Ok(Ok(h)) = std::env::var("TOP_HEIGHT").map(|s| s.parse()) { + client.top_height = h; + println!("TOP_HEIGHT (found): {h}"); + h + } else { + println!("TOP_HEIGHT (off, using latest): {}", client.top_height); + client.top_height + }; + + println!(); tokio::join!( client.cryptonight_v0(), diff --git a/tests/pow/src/rpc.rs b/tests/pow/src/rpc.rs index 8aea195..557d0ef 100644 --- a/tests/pow/src/rpc.rs +++ b/tests/pow/src/rpc.rs @@ -85,7 +85,6 @@ impl RpcClient { .try_into() .unwrap(); - println!("top_height: {top_height}"); assert!(top_height > 3301441, "node is behind"); Self { @@ -171,6 +170,10 @@ impl RpcClient { let count = TESTED_BLOCK_COUNT.fetch_add(1, Ordering::Release) + 1; + if std::env::var("VERBOSE").is_err() && count % 500 != 0 { + return; + } + let hash = hex::encode(pow_hash); let percent = (count as f64 / top_height as f64) * 100.0;