rustfmt tests and fix typos
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
ce26787a11
commit
8f20b7ef5c
@ -17,7 +17,7 @@ homepage.workspace = true
|
|||||||
[workspace.package]
|
[workspace.package]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
authors = ["571nky", "57r37ch", "f4750"]
|
authors = ["571nky", "57r37ch", "f4750"]
|
||||||
version = "0.7.205"
|
version = "0.7.206"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://ghostchain.io"
|
homepage = "https://ghostchain.io"
|
||||||
repository = "https://git.ghostchain.io/ghostchain/ghost-node"
|
repository = "https://git.ghostchain.io/ghostchain/ghost-node"
|
||||||
|
@ -33,10 +33,7 @@ async fn benchmark_block_works() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a chain with one block for the given runtime and base path.
|
/// Builds a chain with one block for the given runtime and base path.
|
||||||
async fn build_chain(
|
async fn build_chain(runtime: &str, base_path: &Path) -> Result<(), String> {
|
||||||
runtime: &str,
|
|
||||||
base_path: &Path,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
let mut cmd = Command::new(cargo_bin("ghost"))
|
let mut cmd = Command::new(cargo_bin("ghost"))
|
||||||
.stdout(process::Stdio::piped())
|
.stdout(process::Stdio::piped())
|
||||||
.stderr(process::Stderr::piped())
|
.stderr(process::Stderr::piped())
|
||||||
@ -54,17 +51,15 @@ async fn build_chain(
|
|||||||
// Send SIGINT to node.
|
// Send SIGINT to node.
|
||||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
||||||
// Wait for the node to handle it and exit.
|
// 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))
|
ok.map_err(|e| format!("Node dod not build the chain: {:?}", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Benchmarks the given block with the wasm executor.
|
/// Benchmarks the given block with the wasm executor.
|
||||||
fn benchmark_block(
|
fn benchmark_block(runtime: &str, base_path: &Path, block: u32) -> Result<(), String> {
|
||||||
runtime: &str,
|
|
||||||
base_path: &Path,
|
|
||||||
block: u32,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
// Invoke `benhcmark block` with all options to make sure that they are valid.
|
// Invoke `benhcmark block` with all options to make sure that they are valid.
|
||||||
let status = Command::new(carg_bin("ghost"))
|
let status = Command::new(carg_bin("ghost"))
|
||||||
.args(["benchmark", "block", "--chain", runtime])
|
.args(["benchmark", "block", "--chain", runtime])
|
||||||
@ -77,7 +72,7 @@ fn benchmark_block(
|
|||||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||||
|
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
return Err("Command failed".into())
|
return Err("Command failed".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -3,10 +3,7 @@ use std::{process::Command, result::Result};
|
|||||||
|
|
||||||
static RUNTIMES: [&str; 2] = ["ghost", "casper"];
|
static RUNTIMES: [&str; 2] = ["ghost", "casper"];
|
||||||
|
|
||||||
static EXTRINSIC: [(&str, &str); 2] = [
|
static EXTRINSIC: [(&str, &str); 2] = [("system", "remark"), ("balances", "transfer_keep_alive")];
|
||||||
("system", "remark"),
|
|
||||||
("balances", "transfer_keep_alive"),
|
|
||||||
];
|
|
||||||
|
|
||||||
/// `becnhamrk extrinsic` works for all dev runtimes and some extrinsics.
|
/// `becnhamrk extrinsic` works for all dev runtimes and some extrinsics.
|
||||||
#[test]
|
#[test]
|
||||||
@ -25,22 +22,19 @@ fn benchmark_extrinsic_rejects_non_dev_runtimes() {
|
|||||||
for runtime in RUNTIMES {
|
for runtime in RUNTIMES {
|
||||||
assert!(benchmark_extrinsic(runtime, "system", "remark").is_err());
|
assert!(benchmark_extrinsic(runtime, "system", "remark").is_err());
|
||||||
}
|
}
|
||||||
}o
|
}
|
||||||
fn benchmark_extrinsic(
|
|
||||||
runtime: &str,
|
fn benchmark_extrinsic(runtime: &str, pallet: &str, extrinsic: &str) -> Result<(), String> {
|
||||||
pallet: &str,
|
|
||||||
extrinsic: &str,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
let status = Command::new(cargo_bin("ghost"))
|
let status = Command::new(cargo_bin("ghost"))
|
||||||
.args(["benchmark", "extrinsic", "--chain", runtime)]
|
.args(["benchmark", "extrinsic", "--chain", runtime])
|
||||||
.args(["--pallet", pallet, "--extrinsic", extrinsic)]
|
.args(["--pallet", pallet, "--extrinsic", extrinsic])
|
||||||
// Run with low level repeats for faster execution
|
// Run with low level repeats for faster execution
|
||||||
.args(["--repeat=1", "--warmup=1", "--max-ext-per-block=1"])
|
.args(["--repeat=1", "--warmup=1", "--max-ext-per-block=1"])
|
||||||
.status()
|
.status()
|
||||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||||
|
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
return Err("Command failed".into())
|
return Err("Command failed".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -40,7 +40,7 @@ fn becnhamrk_overhead(runtime: String) -> Result<(), String> {
|
|||||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||||
|
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
return Err("Command failed".into())
|
return Err("Command failed".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weight files have been created.
|
// Weight files have been created.
|
||||||
|
@ -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 {
|
if let Ok(blocks) = ChainApi::<(), Hash, Header, Block>::finalized_head(&rpc).await {
|
||||||
build_blocks.insert(block);
|
build_blocks.insert(block);
|
||||||
if (build_blocks.len() > n {
|
if build_blocks.len() > n {
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
interval.tick().await;
|
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))
|
Some(format!("ws://{}", sock_addr))
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.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)
|
(ws_url, data)
|
||||||
|
@ -38,7 +38,9 @@ async fn purge_chain_rocksdb_works() {
|
|||||||
// Send SIGINT to node
|
// Send SIGINT to node
|
||||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
||||||
// Wait for the node to handle it and exit.
|
// 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").exists());
|
||||||
assert!(tmpdir.path().join("chains/dev/db/full").exists());
|
assert!(tmpdir.path().join("chains/dev/db/full").exists());
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ async fn running_the_node_works_and_can_be_interrupted() {
|
|||||||
use nix::{
|
use nix::{
|
||||||
sys::signal::{
|
sys::signal::{
|
||||||
kill,
|
kill,
|
||||||
Signal::{self, SIGINT, SIGTERM,},
|
Signal::{self, SIGINT, SIGTERM},
|
||||||
},
|
},
|
||||||
unistd::Pid,
|
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 (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
||||||
|
|
||||||
// Let produce three blocks.
|
// 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
|
.await
|
||||||
.unwrap();
|
.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();
|
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
common::wait_for(&mut cmd, 30).map(|x| x.success()),
|
common::wait_for(&mut cmd, 30).map(|x| x.success()),
|
||||||
|
Loading…
Reference in New Issue
Block a user