diff --git a/crates/node/src/helpers/process.rs b/crates/node/src/helpers/process.rs index 23057f0..5ffa5f5 100644 --- a/crates/node/src/helpers/process.rs +++ b/crates/node/src/helpers/process.rs @@ -110,8 +110,11 @@ impl Process { } let check_result = - check_function(stdout_line.as_deref(), stderr_line.as_deref()) - .context("Failed to wait for the process to be ready")?; + check_function(stdout_line.as_deref(), stderr_line.as_deref()).context( + format!( + "Failed to wait for the process to be ready - {stdout} - {stderr}" + ), + )?; if check_result { break; @@ -127,10 +130,10 @@ impl Process { ProcessReadinessWaitBehavior::WaitForCommandToExit => { if !child .wait() - .context("Failed waiting for kurtosis run process to finish")? + .context("Failed waiting for process to finish")? .success() { - anyhow::bail!("Failed to initialize kurtosis network",); + anyhow::bail!("Failed to spawn command"); } } } diff --git a/crates/node/src/node_implementations/geth.rs b/crates/node/src/node_implementations/geth.rs index bea3c0b..a9db012 100644 --- a/crates/node/src/node_implementations/geth.rs +++ b/crates/node/src/node_implementations/geth.rs @@ -734,12 +734,44 @@ mod tests { (context, node) } + fn shared_state() -> &'static (TestExecutionContext, GethNode) { + static STATE: LazyLock<(TestExecutionContext, GethNode)> = LazyLock::new(new_node); + &STATE + } + fn shared_node() -> &'static GethNode { - static NODE: LazyLock<(TestExecutionContext, GethNode)> = LazyLock::new(new_node); - &NODE.1 + &shared_state().1 + } + + #[tokio::test] + async fn node_mines_simple_transfer_transaction_and_returns_receipt() { + // Arrange + let (context, node) = shared_state(); + + let provider = node.provider().await.expect("Failed to create provider"); + + let account_address = context + .wallet_configuration + .wallet() + .default_signer() + .address(); + let transaction = TransactionRequest::default() + .to(account_address) + .value(U256::from(100_000_000_000_000u128)); + + // Act + let receipt = provider.send_transaction(transaction).await; + + // Assert + let _ = receipt + .expect("Failed to send the transfer transaction") + .get_receipt() + .await + .expect("Failed to get the receipt for the transfer"); } #[test] + #[ignore = "Ignored since they take a long time to run"] fn version_works() { // Arrange let node = shared_node(); @@ -756,6 +788,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_chain_id_from_node() { // Arrange let node = shared_node(); @@ -769,6 +802,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_gas_limit_from_node() { // Arrange let node = shared_node(); @@ -786,6 +820,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_coinbase_from_node() { // Arrange let node = shared_node(); @@ -803,6 +838,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_difficulty_from_node() { // Arrange let node = shared_node(); @@ -820,6 +856,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_hash_from_node() { // Arrange let node = shared_node(); @@ -837,6 +874,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_timestamp_from_node() { // Arrange let node = shared_node(); @@ -854,6 +892,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_number_from_node() { // Arrange let node = shared_node(); diff --git a/crates/node/src/node_implementations/lighthouse_geth.rs b/crates/node/src/node_implementations/lighthouse_geth.rs index 55a00c4..ab855f5 100644 --- a/crates/node/src/node_implementations/lighthouse_geth.rs +++ b/crates/node/src/node_implementations/lighthouse_geth.rs @@ -307,6 +307,7 @@ impl LighthouseGethNode { }), }, ) + .context("Failed to spawn the kurtosis enclave") .inspect_err(|err| { tracing::error!(?err, "Failed to spawn Kurtosis"); self.shutdown().expect("Failed to shutdown kurtosis"); @@ -899,20 +900,46 @@ impl, P: Provider> ResolverApi impl Node for LighthouseGethNode { #[instrument(level = "info", skip_all, fields(lighthouse_node_id = self.id))] fn shutdown(&mut self) -> anyhow::Result<()> { - if !Command::new(self.kurtosis_binary_path.as_path()) + let mut child = Command::new(self.kurtosis_binary_path.as_path()) .arg("enclave") .arg("rm") .arg("-f") .arg(self.enclave_name.as_str()) - .stdout(Stdio::null()) - .stderr(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) .spawn() - .expect("Failed to spawn the enclave kill command") + .expect("Failed to spawn the enclave kill command"); + + if !child .wait() .expect("Failed to wait for the enclave kill command") .success() { - panic!("Failed to shut down the enclave {}", self.enclave_name) + let stdout = { + let mut stdout = String::default(); + child + .stdout + .take() + .expect("Should be piped") + .read_to_string(&mut stdout) + .context("Failed to read stdout of kurtosis inspect to string")?; + stdout + }; + let stderr = { + let mut stderr = String::default(); + child + .stderr + .take() + .expect("Should be piped") + .read_to_string(&mut stderr) + .context("Failed to read stderr of kurtosis inspect to string")?; + stderr + }; + + panic!( + "Failed to shut down the enclave {} - stdout: {stdout}, stderr: {stderr}", + self.enclave_name + ) } drop(self.process.take()); @@ -1130,6 +1157,7 @@ mod tests { } #[test] + #[ignore = "Ignored since they take a long time to run"] fn version_works() { // Arrange let (_context, node) = new_node(); @@ -1146,6 +1174,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_chain_id_from_node() { // Arrange let (_context, node) = new_node(); @@ -1159,6 +1188,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_gas_limit_from_node() { // Arrange let (_context, node) = new_node(); @@ -1176,6 +1206,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_coinbase_from_node() { // Arrange let (_context, node) = new_node(); @@ -1193,6 +1224,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_difficulty_from_node() { // Arrange let (_context, node) = new_node(); @@ -1210,6 +1242,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_hash_from_node() { // Arrange let (_context, node) = new_node(); @@ -1227,6 +1260,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_timestamp_from_node() { // Arrange let (_context, node) = new_node(); @@ -1244,6 +1278,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_number_from_node() { // Arrange let (_context, node) = new_node(); diff --git a/crates/node/src/node_implementations/substrate.rs b/crates/node/src/node_implementations/substrate.rs index 8fd4721..fd746a1 100644 --- a/crates/node/src/node_implementations/substrate.rs +++ b/crates/node/src/node_implementations/substrate.rs @@ -1224,6 +1224,7 @@ mod tests { } #[test] + #[ignore = "Ignored since they take a long time to run"] fn test_init_generates_chainspec_with_balances() { let genesis_content = r#" { @@ -1277,6 +1278,7 @@ mod tests { } #[test] + #[ignore = "Ignored since they take a long time to run"] fn test_parse_genesis_alloc() { // Create test genesis file let genesis_json = r#" @@ -1319,6 +1321,7 @@ mod tests { } #[test] + #[ignore = "Ignored since they take a long time to run"] fn print_eth_to_substrate_mappings() { let eth_addresses = vec![ "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1", @@ -1334,6 +1337,7 @@ mod tests { } #[test] + #[ignore = "Ignored since they take a long time to run"] fn test_eth_to_substrate_address() { let cases = vec![ ( @@ -1364,6 +1368,7 @@ mod tests { } #[test] + #[ignore = "Ignored since they take a long time to run"] fn version_works() { let node = shared_node(); @@ -1376,6 +1381,7 @@ mod tests { } #[test] + #[ignore = "Ignored since they take a long time to run"] fn eth_rpc_version_works() { let node = shared_node(); @@ -1388,6 +1394,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_chain_id_from_node() { // Arrange let node = shared_node(); @@ -1401,6 +1408,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_gas_limit_from_node() { // Arrange let node = shared_node(); @@ -1418,6 +1426,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_coinbase_from_node() { // Arrange let node = shared_node(); @@ -1435,6 +1444,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_difficulty_from_node() { // Arrange let node = shared_node(); @@ -1452,6 +1462,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_hash_from_node() { // Arrange let node = shared_node(); @@ -1469,6 +1480,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_timestamp_from_node() { // Arrange let node = shared_node(); @@ -1486,6 +1498,7 @@ mod tests { } #[tokio::test] + #[ignore = "Ignored since they take a long time to run"] async fn can_get_block_number_from_node() { // Arrange let node = shared_node();