#![cfg(unix)]
use std::os::unix::process::ExitStatusExt;
use std::process::{Command, Stdio};
use std::time::Duration;
#[test]
fn sigint_death_reports_signal_status() {
let private_key_hex = hex::encode([1u8; 32]);
let mut child = Command::new(env!("CARGO_BIN_EXE_aleph"))
.args([
"--ccn",
"http://127.0.0.1:1/",
"post",
"create",
"--type",
"test",
"--private-key",
&private_key_hex,
"--chain",
"eth",
"--dry-run",
])
.stdin(Stdio::piped())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.expect("failed to spawn aleph binary");
let _stdin = child.stdin.take().expect("child stdin was piped");
std::thread::sleep(Duration::from_millis(500));
unsafe { libc::kill(child.id() as libc::pid_t, libc::SIGINT) };
let status = child.wait().expect("failed to wait on aleph binary");
assert_eq!(
status.signal(),
Some(libc::SIGINT),
"expected death by SIGINT so the shell redraws its prompt on a fresh \
line, got {status:?}"
);
}