From e7f4f6966d3188350c58363c3337a5edcb6eb76f Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Wed, 27 Nov 2024 14:37:00 +0100 Subject: [PATCH] serial attribute to force cargo test to run chain sim tests sequentially --- .../src/contract/generate_snippets/snippet_crate_gen.rs | 1 + .../src/contract/generate_snippets/snippet_template_gen.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/framework/meta-lib/src/contract/generate_snippets/snippet_crate_gen.rs b/framework/meta-lib/src/contract/generate_snippets/snippet_crate_gen.rs index 8b9e840363..16e36a6aae 100644 --- a/framework/meta-lib/src/contract/generate_snippets/snippet_crate_gen.rs +++ b/framework/meta-lib/src/contract/generate_snippets/snippet_crate_gen.rs @@ -97,6 +97,7 @@ version = "{last_release_version}" clap = {{ version = "4.4.7", features = ["derive"] }} serde = {{ version = "1.0", features = ["derive"] }} toml = "0.8.6" +serial_test = {{ version = "3.2.0" }} [features] chain-simulator-tests = [] diff --git a/framework/meta-lib/src/contract/generate_snippets/snippet_template_gen.rs b/framework/meta-lib/src/contract/generate_snippets/snippet_template_gen.rs index 540ae47437..816ad76572 100644 --- a/framework/meta-lib/src/contract/generate_snippets/snippet_template_gen.rs +++ b/framework/meta-lib/src/contract/generate_snippets/snippet_template_gen.rs @@ -231,13 +231,16 @@ pub(crate) fn write_chain_sim_test_to_file(file: &mut File, crate_name: &str) { file, r#"use multiversx_sc_snippets::imports::*; use rust_interact::ContractInteract; +use serial_test::serial; // Simple deploy test that runs using the chain simulator configuration. // In order for this test to work, make sure that the `config.toml` file contains the chain simulator config (or choose it manually) // The chain simulator should already be installed and running before attempting to run this test. // The chain-simulator-tests feature should be present in Cargo.toml. // Can be run with `sc-meta test -c`. +// The `#[serial]` attribute should be added to all interactor tests so that we avoid racing problems. #[tokio::test] +#[serial] #[cfg_attr(not(feature = "chain-simulator-tests"), ignore)] async fn deploy_test_{crate_name}_cs() {{ let mut interactor = ContractInteract::new().await;