rustfmt tests and fix typos

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-07-29 14:45:41 +03:00
parent ce26787a11
commit 8f20b7ef5c
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
7 changed files with 30 additions and 33 deletions

View File

@ -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"

View File

@ -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(())

View File

@ -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(())

View File

@ -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.

View File

@ -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)

View File

@ -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());

View File

@ -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()),