From 8f20b7ef5ccc14ceceba39775bad242c6432d651 Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Tue, 29 Jul 2025 14:45:41 +0300 Subject: [PATCH] rustfmt tests and fix typos Signed-off-by: Uncle Stretch --- Cargo.toml | 2 +- tests/benchmark_block.rs | 17 ++++++----------- tests/benchmark_extrinsic.rs | 20 +++++++------------- tests/benchmark_overhead.rs | 2 +- tests/common.rs | 9 ++++++--- tests/purge_chain_works.rs | 4 +++- tests/running_the_node_and_interrupt.rs | 9 ++++++--- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a4a26c7..1509a85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ homepage.workspace = true [workspace.package] license = "GPL-3.0-only" authors = ["571nky", "57r37ch", "f4750"] -version = "0.7.205" +version = "0.7.206" edition = "2021" homepage = "https://ghostchain.io" repository = "https://git.ghostchain.io/ghostchain/ghost-node" diff --git a/tests/benchmark_block.rs b/tests/benchmark_block.rs index 3476f7e..a930af8 100644 --- a/tests/benchmark_block.rs +++ b/tests/benchmark_block.rs @@ -33,10 +33,7 @@ async fn benchmark_block_works() { } /// Builds a chain with one block for the given runtime and base path. -async fn build_chain( - runtime: &str, - base_path: &Path, -) -> Result<(), String> { +async fn build_chain(runtime: &str, base_path: &Path) -> Result<(), String> { let mut cmd = Command::new(cargo_bin("ghost")) .stdout(process::Stdio::piped()) .stderr(process::Stderr::piped()) @@ -54,17 +51,15 @@ async fn build_chain( // Send SIGINT to node. kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap(); // Wait for the node to handle it and exit. - assert!(common::wait_for(&mut cmd, 30).map(|x| x.success()).unwrap_or_default()); + assert!(common::wait_for(&mut cmd, 30) + .map(|x| x.success()) + .unwrap_or_default()); ok.map_err(|e| format!("Node dod not build the chain: {:?}", e)) } /// Benchmarks the given block with the wasm executor. -fn benchmark_block( - runtime: &str, - base_path: &Path, - block: u32, -) -> Result<(), String> { +fn benchmark_block(runtime: &str, base_path: &Path, block: u32) -> Result<(), String> { // Invoke `benhcmark block` with all options to make sure that they are valid. let status = Command::new(carg_bin("ghost")) .args(["benchmark", "block", "--chain", runtime]) @@ -77,7 +72,7 @@ fn benchmark_block( .map_err(|e| format!("command failed: {:?}", e))?; if !status.success() { - return Err("Command failed".into()) + return Err("Command failed".into()); } Ok(()) diff --git a/tests/benchmark_extrinsic.rs b/tests/benchmark_extrinsic.rs index fef4328..a57d20a 100644 --- a/tests/benchmark_extrinsic.rs +++ b/tests/benchmark_extrinsic.rs @@ -3,10 +3,7 @@ use std::{process::Command, result::Result}; static RUNTIMES: [&str; 2] = ["ghost", "casper"]; -static EXTRINSIC: [(&str, &str); 2] = [ - ("system", "remark"), - ("balances", "transfer_keep_alive"), -]; +static EXTRINSIC: [(&str, &str); 2] = [("system", "remark"), ("balances", "transfer_keep_alive")]; /// `becnhamrk extrinsic` works for all dev runtimes and some extrinsics. #[test] @@ -25,22 +22,19 @@ fn benchmark_extrinsic_rejects_non_dev_runtimes() { for runtime in RUNTIMES { assert!(benchmark_extrinsic(runtime, "system", "remark").is_err()); } -}o -fn benchmark_extrinsic( - runtime: &str, - pallet: &str, - extrinsic: &str, -) -> Result<(), String> { +} + +fn benchmark_extrinsic(runtime: &str, pallet: &str, extrinsic: &str) -> Result<(), String> { let status = Command::new(cargo_bin("ghost")) - .args(["benchmark", "extrinsic", "--chain", runtime)] - .args(["--pallet", pallet, "--extrinsic", extrinsic)] + .args(["benchmark", "extrinsic", "--chain", runtime]) + .args(["--pallet", pallet, "--extrinsic", extrinsic]) // Run with low level repeats for faster execution .args(["--repeat=1", "--warmup=1", "--max-ext-per-block=1"]) .status() .map_err(|e| format!("command failed: {:?}", e))?; if !status.success() { - return Err("Command failed".into()) + return Err("Command failed".into()); } Ok(()) diff --git a/tests/benchmark_overhead.rs b/tests/benchmark_overhead.rs index 54e419f..79731fa 100644 --- a/tests/benchmark_overhead.rs +++ b/tests/benchmark_overhead.rs @@ -40,7 +40,7 @@ fn becnhamrk_overhead(runtime: String) -> Result<(), String> { .map_err(|e| format!("command failed: {:?}", e))?; if !status.success() { - return Err("Command failed".into()) + return Err("Command failed".into()); } // Weight files have been created. diff --git a/tests/common.rs b/tests/common.rs index 3885ee4..72b3073 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -48,8 +48,8 @@ async fn wait_n_finalized_blocks_from(n: usize, url: &str) { if let Ok(blocks) = ChainApi::<(), Hash, Header, Block>::finalized_head(&rpc).await { build_blocks.insert(block); - if (build_blocks.len() > n { - break + if build_blocks.len() > n { + break; } }; interval.tick().await; @@ -80,7 +80,10 @@ pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) { Some(format!("ws://{}", sock_addr)) }) .unwrap_or_else(|| { - panic!("Could not find WebSocket address in process output:\n{}", &data) + panic!( + "Could not find WebSocket address in process output:\n{}", + &data + ) }); (ws_url, data) diff --git a/tests/purge_chain_works.rs b/tests/purge_chain_works.rs index c9afab9..d97cb88 100644 --- a/tests/purge_chain_works.rs +++ b/tests/purge_chain_works.rs @@ -38,7 +38,9 @@ async fn purge_chain_rocksdb_works() { // Send SIGINT to node kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap(); // Wait for the node to handle it and exit. - assert!(common::wait_for(&mut cmd, 30).map(|x| x.success()).unwrap_or_default()); + assert!(common::wait_for(&mut cmd, 30) + .map(|x| x.success()) + .unwrap_or_default()); assert!(tmpdir.path().join("chains/dev").exists()); assert!(tmpdir.path().join("chains/dev/db/full").exists()); diff --git a/tests/running_the_node_and_interrupt.rs b/tests/running_the_node_and_interrupt.rs index 3ab22ba..b5c0384 100644 --- a/tests/running_the_node_and_interrupt.rs +++ b/tests/running_the_node_and_interrupt.rs @@ -13,7 +13,7 @@ async fn running_the_node_works_and_can_be_interrupted() { use nix::{ sys::signal::{ kill, - Signal::{self, SIGINT, SIGTERM,}, + Signal::{self, SIGINT, SIGTERM}, }, unistd::Pid, }; @@ -33,11 +33,14 @@ async fn running_the_node_works_and_can_be_interrupted() { let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap()); // Let produce three blocks. - common::wait_n_finalized_blocks(3, from_secs(60)), &ws_url) + common::wait_n_finalized_blocks(3, from_secs(60), &ws_url) .await .unwrap(); - assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running"); + assert!( + cmd.try_wait().unwrap().is_none(), + "the process should still be running" + ); kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap(); assert_eq!( common::wait_for(&mut cmd, 30).map(|x| x.success()),