From 8a1c33f66b942ce4b8b0c04796f5a3e947ce0562 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 2 Jan 2025 16:55:43 +0000 Subject: [PATCH] Log --- crates/e2e/src/setup/mod.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/crates/e2e/src/setup/mod.rs b/crates/e2e/src/setup/mod.rs index 6971a634fa..43dafcd4e9 100644 --- a/crates/e2e/src/setup/mod.rs +++ b/crates/e2e/src/setup/mod.rs @@ -195,6 +195,7 @@ async fn run( let _lock = NODE_MUTEX.lock(); let (node, web3) = spawn_node_with_retries(&fork, 3).await; + tracing::info!("Node started"); services::clear_database().await; // Hack: the closure may actually be unwind unsafe; moreover, `catch_unwind` @@ -203,10 +204,9 @@ async fn run( // is supposed to be used in a test environment. let result = AssertUnwindSafe(f(web3.clone())).catch_unwind().await; - let node = node.lock().unwrap().take(); - if let Some(mut node) = node { - node.kill().await; - } + let mut node = node.lock().unwrap(); + node.kill().await; + services::clear_database().await; if let Err(err) = result { @@ -216,18 +216,18 @@ async fn run( async fn try_spawn_node_and_check( fork: &Option<(String, Option)>, -) -> Option<(Arc>>, Web3)> { +) -> Option<(Arc>, Web3)> { let node = match fork { Some((fork_url, block_number)) => Node::forked(fork_url.clone(), *block_number).await, None => Node::new().await, }; - let node = Arc::new(Mutex::new(Some(node))); + let node = Arc::new(Mutex::new(node)); let node_panic_handle = node.clone(); observe::panic_hook::prepend_panic_handler(Box::new(move |_| { // Drop node in panic handler because `.catch_unwind()` does not catch all // panics - let _ = node_panic_handle.lock().unwrap().take(); + let _ = node_panic_handle.lock().unwrap(); })); let http = create_test_transport(NODE_HOST); @@ -241,8 +241,11 @@ async fn try_spawn_node_and_check( match mine_check { Ok(Ok(_)) => Some((node, web3)), _ => { - let node = node.lock().unwrap().take(); - if let Some(mut node) = node { + let node_to_kill = { + let mut guard = node.lock().unwrap(); + guard.take() + }; + if let Some(mut node) = node_to_kill { node.kill().await; } None @@ -253,7 +256,7 @@ async fn try_spawn_node_and_check( async fn spawn_node_with_retries( fork: &Option<(String, Option)>, max_attempts: u32, -) -> (Arc>>, Web3) { +) -> (Arc>, Web3) { let mut attempts = 0; while attempts < max_attempts {