Skip to content

Commit e13511b

Browse files
authored
Fix: relay chain arguments need a first argument "command" (#65)
Otherwise the first positional argument is just swallowed Fixes #62 Forked at: cd1eb37 Parent branch: origin/master
1 parent cd1eb37 commit e13511b

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

test/parachain/src/command.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
9898

9999
polkadot_config.config_dir = config.in_chain_config_dir("polkadot");
100100

101-
let polkadot_opt: PolkadotCli = sc_cli::from_iter(opt.relaychain_args, &version);
101+
let polkadot_opt: PolkadotCli = sc_cli::from_iter(
102+
[version.executable_name.to_string()].iter().chain(opt.relaychain_args.iter()),
103+
&version,
104+
);
102105
let allow_private_ipv4 = !polkadot_opt.run.network_config.no_private_ipv4;
103106

104107
polkadot_config.rpc_http = Some(DEFAULT_POLKADOT_RPC_HTTP.parse().unwrap());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2020 Parity Technologies (UK) Ltd.
2+
// This file is part of Substrate.
3+
4+
// Substrate is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Substrate is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
16+
17+
use assert_cmd::cargo::cargo_bin;
18+
use std::{convert::TryInto, process::Command, thread, time::Duration, fs};
19+
20+
mod common;
21+
22+
#[test]
23+
#[cfg(unix)]
24+
fn polkadot_argument_parsing() {
25+
use nix::sys::signal::{kill, Signal::{self, SIGINT, SIGTERM}};
26+
use nix::unistd::Pid;
27+
28+
fn run_command_and_kill(signal: Signal) {
29+
let _ = fs::remove_dir_all("polkadot_argument_parsing");
30+
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
31+
.args(&[
32+
"-d", "polkadot_argument_parsing", "--", "--bootnodes",
33+
"/ip4/127.0.0.1/tcp/30333/p2p/Qmbx43psh7LVkrYTRXisUpzCubbgYojkejzAgj5mteDnxy",
34+
"--bootnodes",
35+
"/ip4/127.0.0.1/tcp/50500/p2p/Qma6SpS7tzfCrhtgEVKR9Uhjmuv55ovC3kY6y6rPBxpWd",
36+
])
37+
.spawn()
38+
.unwrap();
39+
40+
thread::sleep(Duration::from_secs(20));
41+
assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
42+
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
43+
assert_eq!(
44+
common::wait_for(&mut cmd, 30).map(|x| x.success()),
45+
Some(true),
46+
"the process must exit gracefully after signal {}",
47+
signal,
48+
);
49+
}
50+
51+
run_command_and_kill(SIGINT);
52+
run_command_and_kill(SIGTERM);
53+
}

0 commit comments

Comments
 (0)