From 987aa11c141d12d748210e3e599d64d616363d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Fri, 26 Apr 2024 16:57:11 +0200 Subject: [PATCH] Integration test: making it cooler! (#1821) * basic structure * add macro impl * adapt example test cases * add macro to tests * minor doc change * taplo --- Cargo.lock | 11 +++ Cargo.toml | 2 + runtime/integration-tests/Cargo.toml | 1 + .../integration-tests/procedural/Cargo.toml | 24 +++++++ .../integration-tests/procedural/src/lib.rs | 70 +++++++++++++++++++ .../integration-tests/procedural/tests/lib.rs | 11 +++ .../src/generic/cases/account_derivation.rs | 13 ++-- .../src/generic/cases/block_rewards.rs | 7 +- .../src/generic/cases/ethereum_transaction.rs | 3 +- .../src/generic/cases/example.rs | 11 ++- .../src/generic/cases/investments.rs | 3 +- .../src/generic/cases/loans.rs | 11 ++- .../src/generic/cases/oracles.rs | 26 +++---- .../src/generic/cases/precompile.rs | 3 +- .../src/generic/cases/proxy.rs | 39 +++++------ .../src/generic/cases/restricted_transfers.rs | 15 ++-- runtime/integration-tests/src/generic/mod.rs | 3 + runtime/integration-tests/src/lib.rs | 4 ++ 18 files changed, 183 insertions(+), 74 deletions(-) create mode 100644 runtime/integration-tests/procedural/Cargo.toml create mode 100644 runtime/integration-tests/procedural/src/lib.rs create mode 100644 runtime/integration-tests/procedural/tests/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 8bc060264d..7a5f1779b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11742,6 +11742,7 @@ dependencies = [ "polkadot-runtime-parachains", "rococo-runtime", "runtime-common", + "runtime-integration-tests-proc-macro", "sc-block-builder", "sc-client-api", "sc-executor", @@ -11769,6 +11770,16 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "runtime-integration-tests-proc-macro" +version = "0.1.0" +dependencies = [ + "prettyplease 0.2.17", + "proc-macro2", + "quote", + "syn 2.0.57", +] + [[package]] name = "rustc-demangle" version = "0.1.23" diff --git a/Cargo.toml b/Cargo.toml index b5163df121..1e931f9f96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ members = [ "runtime/development", "runtime/common", "runtime/integration-tests", + "runtime/integration-tests/procedural", ] [workspace.package] @@ -275,6 +276,7 @@ runtime-common = { path = "runtime/common", default-features = false } development-runtime = { path = "runtime/development", default-features = false } altair-runtime = { path = "runtime/altair", default-features = false } centrifuge-runtime = { path = "runtime/centrifuge", default-features = false } +runtime-integration-tests-proc-macro = { path = "runtime/integration-tests/procedural" } # Build dependencies substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } diff --git a/runtime/integration-tests/Cargo.toml b/runtime/integration-tests/Cargo.toml index 272647696d..75e436d9f6 100644 --- a/runtime/integration-tests/Cargo.toml +++ b/runtime/integration-tests/Cargo.toml @@ -81,6 +81,7 @@ cfg-utils = { workspace = true, features = ["std"] } development-runtime = { workspace = true, features = ["std"] } liquidity-pools-gateway-routers = { workspace = true, features = ["std"] } runtime-common = { workspace = true, features = ["std"] } +runtime-integration-tests-proc-macro = { workspace = true } # Pallet list axelar-gateway-precompile = { workspace = true, features = ["std"] } diff --git a/runtime/integration-tests/procedural/Cargo.toml b/runtime/integration-tests/procedural/Cargo.toml new file mode 100644 index 0000000000..0415cb3393 --- /dev/null +++ b/runtime/integration-tests/procedural/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "runtime-integration-tests-proc-macro" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +documentation.workspace = true + +[lib] +proc-macro = true + +[dependencies] +prettyplease = "0.2" +proc-macro2 = "1.0" +quote = "1.0" +syn = { version = "2.0", features = ["full", "extra-traits"] } + +[features] +default = [] + +# Enable this macro to show the proc macros unrolled when compiling +debug-proc-macros = [] diff --git a/runtime/integration-tests/procedural/src/lib.rs b/runtime/integration-tests/procedural/src/lib.rs new file mode 100644 index 0000000000..5eb07d3698 --- /dev/null +++ b/runtime/integration-tests/procedural/src/lib.rs @@ -0,0 +1,70 @@ +use proc_macro::TokenStream; +use quote::quote; +use syn::{parse_macro_input, Expr, ItemFn}; + +/// Test the function against different runtimes +/// +/// ```rust,ignore +/// use crate::generic::config::Runtime; +/// +/// #[test_runtimes([development, altair, centrifuge])] +/// fn foo { +/// // Your test here... +/// } +/// ``` +/// You can test all runtimes also as: +/// ```rust,ignore +/// use crate::generic::config::Runtime; +/// +/// #[test_runtimes(all)] +/// fn foo { +/// // Your test here... +/// } +/// ``` +/// +/// You can test for fudge support adding the bound: +/// ```rust,ignore +/// use crate::generic::{config::Runtime, envs::fudge_env::FudgeSupport}; +/// +/// #[test_runtimes(all)] +/// fn foo { +/// // Your test here... +/// } +/// ``` +/// +/// For the following command: `cargo test -p runtime-integration-tests foo`, +/// it will generate the following output: +/// +/// ```text +/// test generic::foo::altair ... ok +/// test generic::foo::development ... ok +/// test generic::foo::centrifuge ... ok +/// ``` +/// +/// Available input for the argument is: +/// - Any combination of `development`, `altair`, `centrifuge` inside `[]`. +/// - The world `all`. +#[proc_macro_attribute] +pub fn test_runtimes(args: TokenStream, input: TokenStream) -> TokenStream { + let args = parse_macro_input!(args as Expr); + let func = parse_macro_input!(input as ItemFn); + + let func_name = &func.sig.ident; + + quote! { + crate::test_for_runtimes!(#args, #func_name); + #func + } + .into() +} + +/// Wrapper over test_runtime to print the output +#[proc_macro_attribute] +pub fn __dbg_test_runtimes(args: TokenStream, input: TokenStream) -> TokenStream { + let tokens = test_runtimes(args, input); + let file = syn::parse_file(&tokens.to_string()).unwrap(); + + println!("{}", prettyplease::unparse(&file)); + + TokenStream::default() +} diff --git a/runtime/integration-tests/procedural/tests/lib.rs b/runtime/integration-tests/procedural/tests/lib.rs new file mode 100644 index 0000000000..ff5928ed13 --- /dev/null +++ b/runtime/integration-tests/procedural/tests/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused)] +#![cfg(feature = "debug-proc-macros")] + +#[macro_use] +extern crate runtime_integration_tests_proc_macro; + +#[__dbg_test_runtimes(all)] +fn macro_runtimes() {} + +#[__dbg_test_runtimes([development, altair, centrifuge])] +fn macro_runtimes_list() {} diff --git a/runtime/integration-tests/src/generic/cases/account_derivation.rs b/runtime/integration-tests/src/generic/cases/account_derivation.rs index 3ad950f10f..d25222df4a 100644 --- a/runtime/integration-tests/src/generic/cases/account_derivation.rs +++ b/runtime/integration-tests/src/generic/cases/account_derivation.rs @@ -50,6 +50,7 @@ fn evm_derivation_copy(chain_id: u64) -> AccountId { AccountId::new(bytes) } +#[test_runtimes(all)] fn local_evm_account() { let env = RuntimeEnv::::default(); @@ -70,6 +71,7 @@ fn local_evm_account() { ); } +#[test_runtimes(all)] fn lp_evm_account() { let env = RuntimeEnv::::default(); @@ -87,6 +89,7 @@ fn lp_evm_account() { assert_eq!(evm_derivation_copy(RANDOM_EVM_ID), derived); } +#[test_runtimes(all)] fn relay_chain_account() { let env = RuntimeEnv::::default(); @@ -129,6 +132,7 @@ fn relay_chain_account() { ); } +#[test_runtimes(all)] fn sibling_chain_account() { let env = RuntimeEnv::::default(); @@ -177,6 +181,7 @@ fn sibling_chain_account() { ); } +#[test_runtimes(all)] fn remote_account_on_relay() { let env = RuntimeEnv::::default(); @@ -205,6 +210,7 @@ fn remote_account_on_relay() { ); } +#[test_runtimes(all)] fn remote_account_on_sibling() { let env = RuntimeEnv::::default(); @@ -235,10 +241,3 @@ fn remote_account_on_sibling() { derived ); } - -crate::test_for_runtimes!(all, local_evm_account); -crate::test_for_runtimes!(all, lp_evm_account); -crate::test_for_runtimes!(all, relay_chain_account); -crate::test_for_runtimes!(all, sibling_chain_account); -crate::test_for_runtimes!(all, remote_account_on_relay); -crate::test_for_runtimes!(all, remote_account_on_sibling); diff --git a/runtime/integration-tests/src/generic/cases/block_rewards.rs b/runtime/integration-tests/src/generic/cases/block_rewards.rs index dedd921592..48fb58ca6b 100644 --- a/runtime/integration-tests/src/generic/cases/block_rewards.rs +++ b/runtime/integration-tests/src/generic/cases/block_rewards.rs @@ -22,7 +22,7 @@ use crate::{ utils::accounts::{default_accounts, Keyring}, }; -crate::test_for_runtimes!(all, block_rewards_api); +#[test_runtimes(all)] fn block_rewards_api() { const STAKER: Keyring = Keyring::Alice; @@ -59,10 +59,7 @@ fn block_rewards_api() { }); } -crate::test_for_runtimes!( - [development, altair, centrifuge], - collator_list_synchronized -); +#[test_runtimes(all)] fn collator_list_synchronized() { RuntimeEnv::::from_parachain_storage( Genesis::default() diff --git a/runtime/integration-tests/src/generic/cases/ethereum_transaction.rs b/runtime/integration-tests/src/generic/cases/ethereum_transaction.rs index 68517787fd..a008a1533c 100644 --- a/runtime/integration-tests/src/generic/cases/ethereum_transaction.rs +++ b/runtime/integration-tests/src/generic/cases/ethereum_transaction.rs @@ -25,6 +25,7 @@ use crate::generic::{ // } pub const TEST_CONTRACT_CODE: &str = "608060405234801561001057600080fd5b50610113806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063c2985578146037578063febb0f7e146057575b600080fd5b603d605f565b604051808215151515815260200191505060405180910390f35b605d6068565b005b60006001905090565b600060db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f6572726f725f6d7367000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b56fea2646970667358221220fde68a3968e0e99b16fabf9b2997a78218b32214031f8e07e2c502daf603a69e64736f6c63430006060033"; +#[test_runtimes([development])] fn call() { RuntimeEnv::::default().parachain_state_mut(|| { // Addresses must be high enough to not map to the precompile space. @@ -100,5 +101,3 @@ fn call() { .unwrap(); }); } - -crate::test_for_runtimes!([development], call); diff --git a/runtime/integration-tests/src/generic/cases/example.rs b/runtime/integration-tests/src/generic/cases/example.rs index b84d5cd14b..c06a8cec6e 100644 --- a/runtime/integration-tests/src/generic/cases/example.rs +++ b/runtime/integration-tests/src/generic/cases/example.rs @@ -16,6 +16,7 @@ use crate::{ utils::accounts::Keyring, }; +#[test_runtimes([development, altair, centrifuge])] fn transfer_balance() { const TRANSFER: Balance = 1000 * CFG; const FOR_FEES: Balance = 1 * CFG; @@ -70,6 +71,7 @@ fn transfer_balance() { } // Identical to `transfer_balance()` test but using fudge. +#[test_runtimes([development, altair, centrifuge])] fn fudge_transfer_balance() { const TRANSFER: Balance = 1000 * CFG; const FOR_FEES: Balance = 1 * CFG; @@ -128,6 +130,7 @@ fn fudge_transfer_balance() { }); } +#[test_runtimes(all)] fn call_api() { let env = RuntimeEnv::::default(); @@ -141,6 +144,7 @@ fn call_api() { }) } +#[test_runtimes(all)] fn fudge_call_api() { let env = FudgeEnv::::default(); @@ -157,6 +161,7 @@ fn fudge_call_api() { }) } +#[test_runtimes(all)] fn pass_time_one_block() { let mut env = RuntimeEnv::::default(); @@ -169,9 +174,3 @@ fn pass_time_one_block() { assert_eq!((after - before).into_seconds(), SECONDS_PER_YEAR) } - -crate::test_for_runtimes!([development, altair, centrifuge], transfer_balance); -crate::test_for_runtimes!(all, call_api); -crate::test_for_runtimes!(all, fudge_transfer_balance); -crate::test_for_runtimes!(all, fudge_call_api); -crate::test_for_runtimes!(all, pass_time_one_block); diff --git a/runtime/integration-tests/src/generic/cases/investments.rs b/runtime/integration-tests/src/generic/cases/investments.rs index cacd0b53cc..f229bde9f0 100644 --- a/runtime/integration-tests/src/generic/cases/investments.rs +++ b/runtime/integration-tests/src/generic/cases/investments.rs @@ -63,6 +63,7 @@ mod common { } } +#[test_runtimes(all)] fn investment_portfolio_single_tranche() { let mut env = common::initialize_state_for_investments::, T>(); @@ -189,5 +190,3 @@ fn investment_portfolio_single_tranche() { )] ); } - -crate::test_for_runtimes!(all, investment_portfolio_single_tranche); diff --git a/runtime/integration-tests/src/generic/cases/loans.rs b/runtime/integration-tests/src/generic/cases/loans.rs index 819c14db25..dc9aaac873 100644 --- a/runtime/integration-tests/src/generic/cases/loans.rs +++ b/runtime/integration-tests/src/generic/cases/loans.rs @@ -273,6 +273,7 @@ mod call { /// - borrow from the loan /// - fully repay the loan until /// - close the loan +#[test_runtimes(all)] fn internal_priced() { let mut env = common::initialize_state_for_loans::, T>(); @@ -310,6 +311,7 @@ fn internal_priced() { } /// Test using oracles to price the loan +#[test_runtimes(all)] fn oracle_priced() { let mut env = common::initialize_state_for_loans::, T>(); @@ -365,6 +367,7 @@ fn oracle_priced() { /// Test using oracles to valuate a portfolio. /// The oracle values used by the portfilio comes from the oracle /// collection +#[test_runtimes(all)] fn portfolio_valuated_by_oracle() { let mut env = common::initialize_state_for_loans::, T>(); @@ -421,6 +424,7 @@ fn portfolio_valuated_by_oracle() { assert_eq!(present_value_price_b, total_portfolio_value.0); } +#[test_runtimes(all)] fn update_maturity_extension() { let mut env = common::initialize_state_for_loans::, T>(); @@ -457,6 +461,7 @@ fn update_maturity_extension() { .unwrap(); } +#[test_runtimes(all)] fn fake_oracle_portfolio_api() { let mut env = common::initialize_state_for_loans::, T>(); @@ -511,9 +516,3 @@ fn fake_oracle_portfolio_api() { ); }); } - -crate::test_for_runtimes!(all, internal_priced); -crate::test_for_runtimes!(all, oracle_priced); -crate::test_for_runtimes!(all, portfolio_valuated_by_oracle); -crate::test_for_runtimes!(all, update_maturity_extension); -crate::test_for_runtimes!(all, fake_oracle_portfolio_api); diff --git a/runtime/integration-tests/src/generic/cases/oracles.rs b/runtime/integration-tests/src/generic/cases/oracles.rs index 3e0d2dd380..14124b582c 100644 --- a/runtime/integration-tests/src/generic/cases/oracles.rs +++ b/runtime/integration-tests/src/generic/cases/oracles.rs @@ -23,14 +23,11 @@ mod ratio_provider { use runtime_common::oracle::Feeder; use sp_runtime::{traits::One, FixedPointNumber}; - use crate::{ - generic::{ - config::Runtime, - env::Env, - envs::runtime_env::RuntimeEnv, - utils::currency::{register_currency, CurrencyInfo, CONST_DEFAULT_CUSTOM}, - }, - test_for_runtimes, + use crate::generic::{ + config::Runtime, + env::Env, + envs::runtime_env::RuntimeEnv, + utils::currency::{register_currency, CurrencyInfo, CONST_DEFAULT_CUSTOM}, }; pub struct OtherLocal; @@ -110,6 +107,7 @@ mod ratio_provider { get_rate_with::(key, || {}) } + #[test_runtimes(all)] fn local_to_variant() { assert_eq!( get_rate::((LocalUSDC.id(), DomainUSDC.id())), @@ -117,6 +115,7 @@ mod ratio_provider { ); } + #[test_runtimes(all)] fn variant_to_local() { assert_eq!( get_rate::((DomainUSDC.id(), LocalUSDC.id())), @@ -124,14 +123,17 @@ mod ratio_provider { ); } + #[test_runtimes(all)] fn variant_to_other_local() { assert_eq!(get_rate::((DomainUSDC.id(), OtherLocal.id())), None); } + #[test_runtimes(all)] fn other_local_to_variant() { assert_eq!(get_rate::((OtherLocal.id(), DomainUSDC.id())), None); } + #[test_runtimes(all)] fn variant_to_local_rate_set() { let pair = (LocalUSDC.id(), DomainUSDC.id()); assert_eq!( @@ -147,6 +149,7 @@ mod ratio_provider { ); } + #[test_runtimes(all)] fn local_to_variant_rate_set() { let pair = (LocalUSDC.id(), DomainUSDC.id()); assert_eq!( @@ -161,11 +164,4 @@ mod ratio_provider { Some(Ratio::one()) ); } - - test_for_runtimes!(all, variant_to_local); - test_for_runtimes!(all, local_to_variant); - test_for_runtimes!(all, variant_to_other_local); - test_for_runtimes!(all, other_local_to_variant); - test_for_runtimes!(all, variant_to_local_rate_set); - test_for_runtimes!(all, local_to_variant_rate_set); } diff --git a/runtime/integration-tests/src/generic/cases/precompile.rs b/runtime/integration-tests/src/generic/cases/precompile.rs index 6b8663956a..c4f95cd9b7 100644 --- a/runtime/integration-tests/src/generic/cases/precompile.rs +++ b/runtime/integration-tests/src/generic/cases/precompile.rs @@ -26,6 +26,7 @@ use crate::generic::{ }, }; +#[test_runtimes([development])] fn axelar_precompile_execute() { RuntimeEnv::::from_parachain_storage( Genesis::default() @@ -133,5 +134,3 @@ fn axelar_precompile_execute() { ); }); } - -crate::test_for_runtimes!([development], axelar_precompile_execute); diff --git a/runtime/integration-tests/src/generic/cases/proxy.rs b/runtime/integration-tests/src/generic/cases/proxy.rs index a606944618..7f2d059986 100644 --- a/runtime/integration-tests/src/generic/cases/proxy.rs +++ b/runtime/integration-tests/src/generic/cases/proxy.rs @@ -137,6 +137,7 @@ fn configure_proxy_and_call( .unwrap() } +#[test_runtimes([development])] fn development_transfer_with_proxy_transfer() where T: pallet_proxy::Config, @@ -146,6 +147,7 @@ where )); } +#[test_runtimes([development])] fn development_transfer_with_proxy_borrow() where T: pallet_proxy::Config, @@ -156,6 +158,7 @@ where ); } +#[test_runtimes([development])] fn development_transfer_with_proxy_invest() where T: pallet_proxy::Config, @@ -166,6 +169,7 @@ where ); } +#[test_runtimes([development])] fn development_x_transfer_with_proxy_transfer() where T: pallet_proxy::Config, @@ -175,6 +179,7 @@ where )); } +#[test_runtimes([development])] fn development_x_transfer_with_proxy_borrow() where T: pallet_proxy::Config, @@ -185,6 +190,7 @@ where ); } +#[test_runtimes([development])] fn development_x_transfer_with_proxy_invest() where T: pallet_proxy::Config, @@ -195,6 +201,7 @@ where ); } +#[test_runtimes([altair])] fn altair_transfer_with_proxy_transfer() where T: pallet_proxy::Config, @@ -204,6 +211,7 @@ where )); } +#[test_runtimes([altair])] fn altair_transfer_with_proxy_borrow() where T: pallet_proxy::Config, @@ -214,6 +222,7 @@ where ); } +#[test_runtimes([altair])] fn altair_transfer_with_proxy_invest() where T: pallet_proxy::Config, @@ -224,6 +233,7 @@ where ); } +#[test_runtimes([altair])] fn altair_x_transfer_with_proxy_transfer() where T: pallet_proxy::Config, @@ -233,6 +243,7 @@ where )); } +#[test_runtimes([altair])] fn altair_x_transfer_with_proxy_borrow() where T: pallet_proxy::Config, @@ -243,6 +254,7 @@ where ); } +#[test_runtimes([altair])] fn altair_x_transfer_with_proxy_invest() where T: pallet_proxy::Config, @@ -253,6 +265,7 @@ where ); } +#[test_runtimes([centrifuge])] fn centrifuge_transfer_with_proxy_transfer() where T: pallet_proxy::Config, @@ -262,6 +275,7 @@ where )); } +#[test_runtimes([centrifuge])] fn centrifuge_transfer_with_proxy_borrow() where T: pallet_proxy::Config, @@ -272,6 +286,7 @@ where ); } +#[test_runtimes([centrifuge])] fn centrifuge_transfer_with_proxy_invest() where T: pallet_proxy::Config, @@ -282,6 +297,7 @@ where ); } +#[test_runtimes([centrifuge])] fn centrifuge_x_transfer_with_proxy_transfer() where T: pallet_proxy::Config, @@ -291,6 +307,7 @@ where )); } +#[test_runtimes([centrifuge])] fn centrifuge_x_transfer_with_proxy_borrow() where T: pallet_proxy::Config, @@ -301,6 +318,7 @@ where ); } +#[test_runtimes([centrifuge])] fn centrifuge_x_transfer_with_proxy_invest() where T: pallet_proxy::Config, @@ -310,24 +328,3 @@ where frame_system::Error::::CallFiltered, ); } - -crate::test_for_runtimes!([development], development_transfer_with_proxy_transfer); -crate::test_for_runtimes!([development], development_transfer_with_proxy_borrow); -crate::test_for_runtimes!([development], development_transfer_with_proxy_invest); -crate::test_for_runtimes!([development], development_x_transfer_with_proxy_transfer); -crate::test_for_runtimes!([development], development_x_transfer_with_proxy_borrow); -crate::test_for_runtimes!([development], development_x_transfer_with_proxy_invest); - -crate::test_for_runtimes!([altair], altair_transfer_with_proxy_transfer); -crate::test_for_runtimes!([altair], altair_transfer_with_proxy_borrow); -crate::test_for_runtimes!([altair], altair_transfer_with_proxy_invest); -crate::test_for_runtimes!([altair], altair_x_transfer_with_proxy_transfer); -crate::test_for_runtimes!([altair], altair_x_transfer_with_proxy_borrow); -crate::test_for_runtimes!([altair], altair_x_transfer_with_proxy_invest); - -crate::test_for_runtimes!([centrifuge], centrifuge_transfer_with_proxy_transfer); -crate::test_for_runtimes!([centrifuge], centrifuge_transfer_with_proxy_borrow); -crate::test_for_runtimes!([centrifuge], centrifuge_transfer_with_proxy_invest); -crate::test_for_runtimes!([centrifuge], centrifuge_x_transfer_with_proxy_transfer); -crate::test_for_runtimes!([centrifuge], centrifuge_x_transfer_with_proxy_borrow); -crate::test_for_runtimes!([centrifuge], centrifuge_x_transfer_with_proxy_invest); diff --git a/runtime/integration-tests/src/generic/cases/restricted_transfers.rs b/runtime/integration-tests/src/generic/cases/restricted_transfers.rs index 0a6d65ad15..7cc55bb548 100644 --- a/runtime/integration-tests/src/generic/cases/restricted_transfers.rs +++ b/runtime/integration-tests/src/generic/cases/restricted_transfers.rs @@ -227,6 +227,7 @@ mod cfg { } } + #[test_runtimes(all)] fn transfer_no_restriction() { let mut env = RuntimeEnv::::from_parachain_storage( Genesis::default() @@ -263,11 +264,13 @@ mod cfg { }); } + #[test_runtimes(all)] fn basic_transfer() { validate_ok::(Keyring::Alice, transfer_ok::()); validate_fail::(Keyring::Alice, transfer_fail::()); } + #[test_runtimes(all)] fn proxy_transfer() { validate_ok::( Keyring::Dave, @@ -287,6 +290,7 @@ mod cfg { ); } + #[test_runtimes(all)] fn batch_proxy_transfer() { validate_ok::( Keyring::Dave, @@ -316,6 +320,7 @@ mod cfg { ); } + #[test_runtimes(all)] fn batch_transfer() { validate_ok::( Keyring::Alice, @@ -335,6 +340,7 @@ mod cfg { ); } + #[test_runtimes(all)] fn batch_all_transfer() { validate_ok::( Keyring::Alice, @@ -354,6 +360,7 @@ mod cfg { ); } + #[test_runtimes(all)] fn remark_transfer() { validate_ok::( Keyring::Alice, @@ -388,12 +395,4 @@ mod cfg { }, ); } - - crate::test_for_runtimes!(all, transfer_no_restriction); - crate::test_for_runtimes!(all, basic_transfer); - crate::test_for_runtimes!(all, proxy_transfer); - crate::test_for_runtimes!(all, batch_proxy_transfer); - crate::test_for_runtimes!(all, batch_transfer); - crate::test_for_runtimes!(all, batch_all_transfer); - crate::test_for_runtimes!(all, remark_transfer); } diff --git a/runtime/integration-tests/src/generic/mod.rs b/runtime/integration-tests/src/generic/mod.rs index 478926f9a4..60bb9ff3f9 100644 --- a/runtime/integration-tests/src/generic/mod.rs +++ b/runtime/integration-tests/src/generic/mod.rs @@ -25,6 +25,8 @@ mod cases { /// Generate tests for the specified runtimes or all runtimes. /// Usage /// +/// NOTE: Your probably want to use `#[test_runtimes]` proc macro instead +/// /// ```rust /// use crate::generic::config::Runtime; /// @@ -49,6 +51,7 @@ mod cases { #[macro_export] macro_rules! test_for_runtimes { ( [ $($runtime_name:ident),* ], $test_name:ident ) => { + #[cfg(test)] mod $test_name { use super::*; diff --git a/runtime/integration-tests/src/lib.rs b/runtime/integration-tests/src/lib.rs index 017b191cb4..76a1eb4c3f 100644 --- a/runtime/integration-tests/src/lib.rs +++ b/runtime/integration-tests/src/lib.rs @@ -16,5 +16,9 @@ // All code in this crate is test related #![cfg(test)] +// Allow `#[test_runtimes]` macro to be called everywhere in the crate +#[macro_use] +extern crate runtime_integration_tests_proc_macro; + mod generic; mod utils;