From 7337e63ac9eece5c9736760e4ea4a9794950780a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Molina?= Date: Fri, 13 Feb 2026 15:03:50 +0100 Subject: [PATCH 1/2] test: harden parachain_lifecycle determinism --- crates/pop-cli/tests/chain.rs | 243 +++++++++++++++++++++------------- 1 file changed, 152 insertions(+), 91 deletions(-) diff --git a/crates/pop-cli/tests/chain.rs b/crates/pop-cli/tests/chain.rs index 9eab10aa7..be4d541cb 100644 --- a/crates/pop-cli/tests/chain.rs +++ b/crates/pop-cli/tests/chain.rs @@ -39,7 +39,8 @@ impl Drop for TestChildProcess { const RPC_CONNECT_TIMEOUT_SECS: u64 = 5; const RPC_REQUEST_TIMEOUT_SECS: u64 = 5; -const COMMAND_TIMEOUT_SECS: u64 = 120; +const COMMAND_WAIT_TIMEOUT_SECS: u64 = 600; +const CALL_COMMAND_TIMEOUT_SECS: u64 = 120; const BLOCK_PRODUCTION_TIMEOUT_SECS: u64 = 60; async fn wait_for_command_success( @@ -64,6 +65,24 @@ async fn wait_for_command_success( Ok(()) } +async fn terminate_child_process(child: &mut Child) -> Result<()> { + if child.try_wait()?.is_some() { + return Ok(()); + } + + #[cfg(unix)] + if let Some(pid) = child.id() { + let _ = std::process::Command::new("kill").args(["-INT", &pid.to_string()]).status(); + if let Ok(Ok(_)) = tokio::time::timeout(Duration::from_secs(20), child.wait()).await { + return Ok(()); + } + } + + let _ = child.kill().await; + let _ = child.wait().await; + Ok(()) +} + async fn rpc_request_string(url: &str, method: &str) -> Option { let client = tokio::time::timeout( Duration::from_secs(RPC_CONNECT_TIMEOUT_SECS), @@ -235,8 +254,7 @@ async fn spawn_network_with_retry( }, Err(e) => { println!("✗ Attempt {} failed: {}", attempt, e); - let _ = process.0.kill().await; - let _ = process.0.wait().await; + let _ = terminate_child_process(&mut process.0).await; if attempt < max_retries { println!("Waiting 5s before retry..."); @@ -277,7 +295,12 @@ async fn generate_all_the_templates() -> Result<()> { "--verify", ], ); - assert!(command.spawn()?.wait().await?.success()); + wait_for_command_success( + &mut command, + COMMAND_WAIT_TIMEOUT_SECS, + "pop new chain