From f5d9990cc8441c8e9e32feb6c3a0ca4c8e8c707e Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Thu, 31 Jul 2025 15:41:36 +0300 Subject: [PATCH] fix: macro for test functions --- .github/workflows/ci.yml | 2 +- integration_tests/src/lib.rs | 87 +++++++++--------------------------- 2 files changed, 22 insertions(+), 67 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7f923d..f3b7c8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ name: General jobs: ubuntu-latest-pipeline: runs-on: ubuntu-latest - timeout-minutes: 60 + timeout-minutes: 120 name: ubuntu-latest-pipeline steps: diff --git a/integration_tests/src/lib.rs b/integration_tests/src/lib.rs index d707be7..b01fdbd 100644 --- a/integration_tests/src/lib.rs +++ b/integration_tests/src/lib.rs @@ -253,6 +253,21 @@ pub async fn test_failure(wrapped_node_core: Arc>) { info!("Success!"); } +macro_rules! test_cleanup_wrap { + ($home_dir:ident, $test_func:ident) => {{ + let res = pre_test($home_dir.clone()).await.unwrap(); + + let wrapped_node_core = res.5.clone(); + + info!("Waiting for first block creation"); + tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; + + $test_func(wrapped_node_core.clone()).await; + + post_test(res).await; + }}; +} + pub async fn main_tests_runner() -> Result<()> { env_logger::init(); @@ -264,78 +279,18 @@ pub async fn main_tests_runner() -> Result<()> { match test_name.as_str() { "test_success_move_to_another_account" => { - let res = pre_test(home_dir).await.unwrap(); - - let wrapped_node_core = res.5.clone(); - - info!("Waiting for first block creation"); - tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; - - test_success_move_to_another_account(wrapped_node_core.clone()).await; - - post_test(res).await; + test_cleanup_wrap!(home_dir, test_success_move_to_another_account); } "test_success" => { - let res = pre_test(home_dir).await.unwrap(); - - let wrapped_node_core = res.5.clone(); - - info!("Waiting for first block creation"); - tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; - - test_success(wrapped_node_core.clone()).await; - - post_test(res).await; + test_cleanup_wrap!(home_dir, test_success); } "test_failure" => { - let res = pre_test(home_dir).await.unwrap(); - - let wrapped_node_core = res.5.clone(); - - info!("Waiting for first block creation"); - tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; - - test_failure(wrapped_node_core.clone()).await; - - post_test(res).await; + test_cleanup_wrap!(home_dir, test_failure); } "all" => { - { - let res = pre_test(home_dir.clone()).await.unwrap(); - - let wrapped_node_core = res.5.clone(); - - info!("Waiting for first block creation"); - tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; - - test_success_move_to_another_account(wrapped_node_core.clone()).await; - - post_test(res).await; - } - { - let res = pre_test(home_dir.clone()).await.unwrap(); - - let wrapped_node_core = res.5.clone(); - - info!("Waiting for first block creation"); - tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; - - test_success(wrapped_node_core.clone()).await; - - post_test(res).await; - } - { - let res = pre_test(home_dir.clone()).await.unwrap(); - - let wrapped_node_core = res.5.clone(); - - info!("Waiting for first block creation"); - tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; - - test_failure(wrapped_node_core.clone()).await; - - post_test(res).await; - } + test_cleanup_wrap!(home_dir, test_success_move_to_another_account); + test_cleanup_wrap!(home_dir, test_success); + test_cleanup_wrap!(home_dir, test_failure); } _ => { anyhow::bail!("Unknown test name");