mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
dir restructure to support more CGP (#1266)
* rerame res to chain-specs * split polkadot-parachains dir * rename dir parachains-common to common Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Wilfried Kopp <wilfried@parity.io> Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
use assert_cmd::cargo::cargo_bin;
|
||||
use std::{
|
||||
path::Path,
|
||||
process::{Command, ExitStatus},
|
||||
};
|
||||
use tempfile::tempdir;
|
||||
|
||||
/// The runtimes that this command supports.
|
||||
static RUNTIMES: [&'static str; 3] = ["westmint", "statemine", "statemint"];
|
||||
|
||||
/// The `benchmark storage` command works for the dev runtimes.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn benchmark_storage_works() {
|
||||
for runtime in RUNTIMES {
|
||||
let tmp_dir = tempdir().expect("could not create a temp dir");
|
||||
let base_path = tmp_dir.path();
|
||||
let runtime = format!("{}-dev", runtime);
|
||||
|
||||
// Benchmarking the storage works and creates the weight file.
|
||||
assert!(benchmark_storage("rocksdb", &runtime, base_path).success());
|
||||
assert!(base_path.join("rocksdb_weights.rs").exists());
|
||||
|
||||
assert!(benchmark_storage("paritydb", &runtime, base_path).success());
|
||||
assert!(base_path.join("paritydb_weights.rs").exists());
|
||||
}
|
||||
}
|
||||
|
||||
/// Invoke the `benchmark storage` sub-command for the given database and runtime.
|
||||
fn benchmark_storage(db: &str, runtime: &str, base_path: &Path) -> ExitStatus {
|
||||
Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["benchmark", "storage", "--chain", runtime])
|
||||
.arg("--db")
|
||||
.arg(db)
|
||||
.arg("--weight-path")
|
||||
.arg(base_path)
|
||||
.args(["--state-version", "0"])
|
||||
.args(["--warmups", "0"])
|
||||
.args(["--add", "100", "--mul", "1.2", "--metric", "p75"])
|
||||
.status()
|
||||
.unwrap()
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2020-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{
|
||||
process::{Child, ExitStatus},
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
/// Wait for the given `child` the given ammount 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: usize) -> Option<ExitStatus> {
|
||||
for _ in 0..secs {
|
||||
match child.try_wait().unwrap() {
|
||||
Some(status) => return Some(status),
|
||||
None => thread::sleep(Duration::from_secs(1)),
|
||||
}
|
||||
}
|
||||
eprintln!("Took to long to exit. Killing...");
|
||||
let _ = child.kill();
|
||||
child.wait().unwrap();
|
||||
|
||||
None
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright 2020-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use assert_cmd::cargo::cargo_bin;
|
||||
use std::{convert::TryInto, fs, process::Command, thread, time::Duration};
|
||||
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[ignore]
|
||||
fn polkadot_argument_parsing() {
|
||||
use nix::{
|
||||
sys::signal::{
|
||||
kill,
|
||||
Signal::{self, SIGINT, SIGTERM},
|
||||
},
|
||||
unistd::Pid,
|
||||
};
|
||||
|
||||
fn run_command_and_kill(signal: Signal) {
|
||||
let _ = fs::remove_dir_all("polkadot_argument_parsing");
|
||||
let mut cmd = Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&[
|
||||
"-d",
|
||||
"polkadot_argument_parsing",
|
||||
"--",
|
||||
"--dev",
|
||||
"--bootnodes",
|
||||
"/ip4/127.0.0.1/tcp/30333/p2p/Qmbx43psh7LVkrYTRXisUpzCubbgYojkejzAgj5mteDnxy",
|
||||
"--bootnodes",
|
||||
"/ip4/127.0.0.1/tcp/50500/p2p/Qma6SpS7tzfCrhtgEVKR9Uhjmuv55ovC3kY6y6rPBxpWde",
|
||||
])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(Duration::from_secs(20));
|
||||
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()),
|
||||
Some(true),
|
||||
"the process must exit gracefully after signal {}",
|
||||
signal,
|
||||
);
|
||||
}
|
||||
|
||||
run_command_and_kill(SIGINT);
|
||||
run_command_and_kill(SIGTERM);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright 2020-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use assert_cmd::cargo::cargo_bin;
|
||||
use std::{convert::TryInto, fs, process::Command, thread, time::Duration};
|
||||
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[ignore]
|
||||
fn interrupt_polkadot_mdns_issue_test() {
|
||||
use nix::{
|
||||
sys::signal::{
|
||||
kill,
|
||||
Signal::{self, SIGINT, SIGTERM},
|
||||
},
|
||||
unistd::Pid,
|
||||
};
|
||||
|
||||
fn run_command_and_kill(signal: Signal) {
|
||||
let _ = fs::remove_dir_all("interrupt_polkadot_mdns_issue_test");
|
||||
let mut cmd = Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["-d", "interrupt_polkadot_mdns_issue_test", "--", "--dev"])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(Duration::from_secs(20));
|
||||
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()),
|
||||
Some(true),
|
||||
"the process must exit gracefully after signal {}",
|
||||
signal,
|
||||
);
|
||||
}
|
||||
|
||||
run_command_and_kill(SIGINT);
|
||||
run_command_and_kill(SIGTERM);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// Copyright 2020-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use assert_cmd::cargo::cargo_bin;
|
||||
use std::{convert::TryInto, process::Command, thread, time::Duration};
|
||||
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[ignore]
|
||||
fn purge_chain_works() {
|
||||
fn run_node_and_stop() -> tempfile::TempDir {
|
||||
use nix::{
|
||||
sys::signal::{kill, Signal::SIGINT},
|
||||
unistd::Pid,
|
||||
};
|
||||
|
||||
let base_path = tempfile::tempdir().unwrap();
|
||||
|
||||
let mut cmd = Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["-d"])
|
||||
.arg(base_path.path())
|
||||
.args(&["--", "--dev"])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
// Let it produce some blocks.
|
||||
thread::sleep(Duration::from_secs(30));
|
||||
assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
|
||||
|
||||
// Stop the process
|
||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
||||
assert!(common::wait_for(&mut cmd, 30).map(|x| x.success()).unwrap_or_default());
|
||||
|
||||
base_path
|
||||
}
|
||||
|
||||
// Check that both databases are deleted
|
||||
{
|
||||
let base_path = run_node_and_stop();
|
||||
|
||||
assert!(base_path.path().join("chains/local_testnet/db/full").exists());
|
||||
assert!(base_path.path().join("polkadot/chains/dev/db/full").exists());
|
||||
|
||||
let status = Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["purge-chain", "-d"])
|
||||
.arg(base_path.path())
|
||||
.arg("-y")
|
||||
.status()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
|
||||
// Make sure that the `parachain_local_testnet` chain folder exists, but the `db` is deleted.
|
||||
assert!(base_path.path().join("chains/local_testnet").exists());
|
||||
assert!(!base_path.path().join("chains/local_testnet/db/full").exists());
|
||||
// assert!(base_path.path().join("polkadot/chains/dev").exists());
|
||||
// assert!(!base_path.path().join("polkadot/chains/dev/db").exists());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright 2020-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use assert_cmd::cargo::cargo_bin;
|
||||
use std::{convert::TryInto, fs, process::Command, thread, time::Duration};
|
||||
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[ignore]
|
||||
fn running_the_node_works_and_can_be_interrupted() {
|
||||
use nix::{
|
||||
sys::signal::{
|
||||
kill,
|
||||
Signal::{self, SIGINT, SIGTERM},
|
||||
},
|
||||
unistd::Pid,
|
||||
};
|
||||
|
||||
fn run_command_and_kill(signal: Signal) {
|
||||
let _ = fs::remove_dir_all("interrupt_test");
|
||||
let mut cmd = Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["-d", "interrupt_test", "--", "--dev"])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(Duration::from_secs(30));
|
||||
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()),
|
||||
Some(true),
|
||||
"the process must exit gracefully after signal {}",
|
||||
signal,
|
||||
);
|
||||
}
|
||||
|
||||
run_command_and_kill(SIGINT);
|
||||
run_command_and_kill(SIGTERM);
|
||||
}
|
||||
Reference in New Issue
Block a user