Skip to content

Commit 91eb29d

Browse files
liamaharonkianenigmakoute
authored andcommitted
Fix try-runtime follow-chain, try-runtime upgrade tuple tests, cli test utils (paritytech#13794)
* new test for try-runtime tuple stuff * fix * remove development comment * formatting * remove todo comment * follow-chain working test * refactor common cli testing utils * fix comment * revert Cargo.lock changes * update Cargo.lock * improve doc comment * fix error typo * update Cargo.lock * feature gate try-runtime test * build_substrate cli test util * feature gate follow_chain tests * move fn start_node to test-utils * improve test pkg name * use tokio Child and Command * remove redundant import * fix ci * fix ci * don't leave hanging processes * improved child process cleanup * use existing KillChildOnDrop * remove redundant comment * Update test-utils/cli/src/lib.rs Co-authored-by: Koute <[email protected]> --------- Co-authored-by: kianenigma <[email protected]> Co-authored-by: Koute <[email protected]>
1 parent 36699c4 commit 91eb29d

19 files changed

+544
-171
lines changed

Cargo.lock

Lines changed: 233 additions & 127 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ tokio-util = { version = "0.7.4", features = ["compat"] }
127127
wait-timeout = "0.2"
128128
substrate-rpc-client = { path = "../../../utils/frame/rpc/client" }
129129
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
130+
substrate-cli-test-utils = { path = "../../../test-utils/cli" }
130131

131132
[build-dependencies]
132133
clap = { version = "4.0.9", optional = true }

bin/node/cli/tests/benchmark_block_works.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use assert_cmd::cargo::cargo_bin;
2323
use std::process::Command;
2424
use tempfile::tempdir;
2525

26-
pub mod common;
26+
use substrate_cli_test_utils as common;
2727

2828
/// `benchmark block` works for the dev runtime using the wasm executor.
2929
#[tokio::test]

bin/node/cli/tests/benchmark_pallet_works.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use assert_cmd::cargo::cargo_bin;
2020
use std::process::Command;
2121

22-
pub mod common;
23-
2422
/// `benchmark pallet` works for the different combinations of `steps` and `repeat`.
2523
#[test]
2624
fn benchmark_pallet_works() {

bin/node/cli/tests/check_block_works.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use assert_cmd::cargo::cargo_bin;
2222
use std::process::Command;
2323
use tempfile::tempdir;
2424

25-
pub mod common;
25+
use substrate_cli_test_utils as common;
2626

2727
#[tokio::test]
2828
async fn check_block_works() {

bin/node/cli/tests/export_import_flow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use regex::Regex;
2323
use std::{fs, path::PathBuf, process::Command};
2424
use tempfile::{tempdir, TempDir};
2525

26-
pub mod common;
26+
use substrate_cli_test_utils as common;
2727

2828
fn contains_error(logged_output: &str) -> bool {
2929
logged_output.contains("Error")

bin/node/cli/tests/inspect_works.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use assert_cmd::cargo::cargo_bin;
2222
use std::process::Command;
2323
use tempfile::tempdir;
2424

25-
pub mod common;
25+
use substrate_cli_test_utils as common;
2626

2727
#[tokio::test]
2828
async fn inspect_works() {

bin/node/cli/tests/purge_chain_works.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use assert_cmd::cargo::cargo_bin;
2020
use std::process::Command;
2121
use tempfile::tempdir;
2222

23-
pub mod common;
23+
use substrate_cli_test_utils as common;
2424

2525
#[tokio::test]
2626
#[cfg(unix)]

bin/node/cli/tests/remember_state_pruning_works.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
use tempfile::tempdir;
2020

21-
pub mod common;
21+
use substrate_cli_test_utils as common;
2222

2323
#[tokio::test]
2424
#[cfg(unix)]

bin/node/cli/tests/running_the_node_and_interrupt.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@
1818

1919
#![cfg(unix)]
2020
use assert_cmd::cargo::cargo_bin;
21-
use nix::{
22-
sys::signal::{
23-
kill,
24-
Signal::{self, SIGINT, SIGTERM},
25-
},
26-
unistd::Pid,
21+
use nix::sys::signal::Signal::{self, SIGINT, SIGTERM};
22+
use std::{
23+
process::{self, Command},
24+
time::Duration,
2725
};
2826
use std::process::{self, Child, Command};
2927
use tempfile::tempdir;
3028

31-
pub mod common;
29+
use substrate_cli_test_utils as common;
3230

3331
#[tokio::test]
3432
async fn running_the_node_works_and_can_be_interrupted() {
@@ -75,17 +73,9 @@ async fn running_the_node_works_and_can_be_interrupted() {
7573

7674
#[tokio::test]
7775
async fn running_two_nodes_with_the_same_ws_port_should_work() {
78-
fn start_node() -> Child {
79-
Command::new(cargo_bin("substrate"))
80-
.stdout(process::Stdio::piped())
81-
.stderr(process::Stdio::piped())
82-
.args(&["--dev", "--tmp", "--ws-port=45789", "--no-hardware-benchmarks"])
83-
.spawn()
84-
.unwrap()
85-
}
86-
87-
let mut first_node = common::KillChildOnDrop(start_node());
88-
let mut second_node = common::KillChildOnDrop(start_node());
76+
common::run_with_timeout(Duration::from_secs(60 * 10), async move {
77+
let mut first_node = common::KillChildOnDrop(common::start_node());
78+
let mut second_node = common::KillChildOnDrop(common::start_node());
8979

9080
let stderr = first_node.stderr.take().unwrap();
9181
let (ws_url, _) = common::find_ws_url_from_output(stderr);

0 commit comments

Comments
 (0)