diff --git a/bin/node/cli/tests/benchmark_pallet_works.rs b/bin/node/cli/tests/benchmark_pallet_works.rs
index 1a278f985da4f..053516b9521d1 100644
--- a/bin/node/cli/tests/benchmark_pallet_works.rs
+++ b/bin/node/cli/tests/benchmark_pallet_works.rs
@@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+#![cfg(feature = "runtime-benchmarks")]
+
use assert_cmd::cargo::cargo_bin;
use std::process::Command;
diff --git a/bin/node/cli/tests/benchmark_storage_works.rs b/bin/node/cli/tests/benchmark_storage_works.rs
index 1f1181218db03..953c07ca7f0db 100644
--- a/bin/node/cli/tests/benchmark_storage_works.rs
+++ b/bin/node/cli/tests/benchmark_storage_works.rs
@@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+#![cfg(feature = "runtime-benchmarks")]
+
use assert_cmd::cargo::cargo_bin;
use std::{
path::Path,
diff --git a/bin/node/cli/tests/common.rs b/bin/node/cli/tests/common.rs
index a0de7300fca90..4c4824391fdc1 100644
--- a/bin/node/cli/tests/common.rs
+++ b/bin/node/cli/tests/common.rs
@@ -20,54 +20,26 @@
use assert_cmd::cargo::cargo_bin;
use nix::{
- sys::signal::{kill, Signal::SIGINT},
+ sys::signal::{kill, Signal, Signal::SIGINT},
unistd::Pid,
};
use node_primitives::{Hash, Header};
+use regex::Regex;
use std::{
io::{BufRead, BufReader, Read},
ops::{Deref, DerefMut},
- path::Path,
- process::{self, Child, Command, ExitStatus},
+ path::{Path, PathBuf},
+ process::{self, Child, Command},
time::Duration,
};
-use tokio::time::timeout;
-/// Wait for the given `child` the given number of `secs`.
-///
-/// Returns the `Some(exit status)` or `None` if the process did not finish in the given time.
-pub fn wait_for(child: &mut Child, secs: u64) -> Result {
- let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(5.min(secs)))
- .map_err(|_| ())?;
- if let Some(exit_status) = result {
- Ok(exit_status)
- } else {
- if secs > 5 {
- eprintln!("Child process taking over 5 seconds to exit gracefully");
- let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(secs - 5))
- .map_err(|_| ())?;
- if let Some(exit_status) = result {
- return Ok(exit_status)
- }
- }
- eprintln!("Took too long to exit (> {} seconds). Killing...", secs);
- let _ = child.kill();
- child.wait().unwrap();
- Err(())
- }
-}
-
-/// Wait for at least n blocks to be finalized within a specified time.
-pub async fn wait_n_finalized_blocks(
- n: usize,
- timeout_secs: u64,
- url: &str,
-) -> Result<(), tokio::time::error::Elapsed> {
- timeout(Duration::from_secs(timeout_secs), wait_n_finalized_blocks_from(n, url)).await
+/// Run the given `future` and panic if the `timeout` is hit.
+pub async fn run_with_timeout(timeout: Duration, future: impl futures::Future