diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4fe56e0..6a196e9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -84,12 +84,14 @@ jobs: run: | ls -l cd generic-template/runtime - cargo llvm-cov --all-features --ignore-filename-regex ".*(weights|benchmark).*" --codecov --output-path lcov.info + cargo llvm-cov --features="runtime-benchmarks" --ignore-filename-regex ".*(weights|benchmark).*" --codecov --output-path lcov.info + cargo clean - name: Generate EVM runtime coverage run: | cd evm-template/runtime - cargo llvm-cov --all-features --ignore-filename-regex ".*(weights|benchmark).*" --codecov --output-path lcov.info + cargo llvm-cov --features="runtime-benchmarks" --ignore-filename-regex ".*(weights|benchmark).*" --codecov --output-path lcov.info + cargo clean - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 diff --git a/evm-template/runtime/src/configs/mod.rs b/evm-template/runtime/src/configs/mod.rs index 3da62ad..21b0cca 100644 --- a/evm-template/runtime/src/configs/mod.rs +++ b/evm-template/runtime/src/configs/mod.rs @@ -120,8 +120,6 @@ impl SystemConfig for OpenZeppelinRuntime { type SlotDuration = ConstU64; type Version = Version; } -#[cfg(feature = "tanssi")] -impl TanssiConfig for OpenZeppelinRuntime {} #[cfg(not(feature = "tanssi"))] impl ConsensusConfig for OpenZeppelinRuntime { type CollatorSelectionUpdateOrigin = CollatorSelectionUpdateOrigin; @@ -215,12 +213,17 @@ impl AssetsConfig for OpenZeppelinRuntime { type ForeignAssetModifierOrigin = EnsureRoot; type WeightToFee = WeightToFee; } +#[cfg(feature = "tanssi")] +impl TanssiConfig for OpenZeppelinRuntime { + type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight; + type AuthoritiesNothing = pallet_cc_authorities_noting::weights::SubstrateWeight; +} impl_openzeppelin_assets!(OpenZeppelinRuntime); impl_openzeppelin_system!(OpenZeppelinRuntime); #[cfg(not(feature = "tanssi"))] impl_openzeppelin_consensus!(OpenZeppelinRuntime); #[cfg(feature = "tanssi")] -impl_openzeppelin_tanssi!(); +impl_openzeppelin_tanssi!(OpenZeppelinRuntime); impl_openzeppelin_governance!(OpenZeppelinRuntime); impl_openzeppelin_xcm!(OpenZeppelinRuntime); impl_openzeppelin_evm!(OpenZeppelinRuntime); diff --git a/evm-template/runtime/src/configs/xcm_config.rs b/evm-template/runtime/src/configs/xcm_config.rs index 397fade..da7f02a 100644 --- a/evm-template/runtime/src/configs/xcm_config.rs +++ b/evm-template/runtime/src/configs/xcm_config.rs @@ -522,6 +522,38 @@ mod testing { #[cfg(test)] mod tests { + + mod is_bridged_concrete_assets_from { + use frame_support::traits::ContainsPair; + use xcm::latest::{Asset, AssetId, Fungibility, Junctions, Location}; + + use crate::configs::{AssetHubLocation, IsBridgedConcreteAssetFrom}; + + #[test] + pub fn is_bridged_concrete_assets_from_contains() { + let asset = Asset { + id: AssetId(Location { parents: 2, interior: Junctions::Here }), + fun: Fungibility::Fungible(100), + }; + assert!(IsBridgedConcreteAssetFrom::::contains( + &asset, + &AssetHubLocation::get() + )) + } + + #[test] + pub fn is_bridged_concrete_assets_from_not_contains() { + let asset = Asset { + id: AssetId(Location { parents: 1, interior: Junctions::Here }), + fun: Fungibility::Fungible(100), + }; + assert!(!IsBridgedConcreteAssetFrom::::contains( + &asset, + &AssetHubLocation::get() + )) + } + } + mod location_conversion { use sp_core::H160; use sp_runtime::traits::{Convert, TryConvert}; diff --git a/evm-template/runtime/src/types.rs b/evm-template/runtime/src/types.rs index bf5c825..4253b17 100644 --- a/evm-template/runtime/src/types.rs +++ b/evm-template/runtime/src/types.rs @@ -206,6 +206,7 @@ mod test { use crate::{types::ProxyType, AssetManager, RuntimeCall}; #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_any() { let call = RuntimeCall::CollatorSelection( pallet_collator_selection::Call::set_desired_candidates { max: 10 }, @@ -215,6 +216,7 @@ mod test { } #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_nontransfer() { let proxy_type = ProxyType::NonTransfer; let valid_call = RuntimeCall::CollatorSelection( @@ -227,6 +229,7 @@ mod test { } #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_cancel_proxy() { let proxy_type = ProxyType::CancelProxy; let invalid_call = RuntimeCall::CollatorSelection( @@ -241,6 +244,7 @@ mod test { } #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_collator() { let proxy_type = ProxyType::Collator; let valid_call = RuntimeCall::CollatorSelection( diff --git a/evm-template/runtime/tests/constants_test.rs b/evm-template/runtime/tests/constants_test.rs index aad57d3..e0eac5a 100644 --- a/evm-template/runtime/tests/constants_test.rs +++ b/evm-template/runtime/tests/constants_test.rs @@ -209,6 +209,7 @@ mod runtime_tests { } #[test] + #[cfg(not(feature = "tanssi"))] fn session_constants() { assert_eq!(configs::Period::get(), 6 * HOURS); @@ -217,6 +218,7 @@ mod runtime_tests { #[test] #[allow(clippy::assertions_on_constants)] + #[cfg(not(feature = "tanssi"))] fn aura_constants() { #[cfg(not(feature = "async-backing"))] assert!(!::AllowMultipleBlocksPerSlot::get()); @@ -227,6 +229,7 @@ mod runtime_tests { } #[test] + #[cfg(not(feature = "tanssi"))] fn collator_selection_constants() { let pallet_id_to_string = |id: PalletId| -> String { core::str::from_utf8(&id.0).unwrap_or_default().to_string() diff --git a/evm-template/runtime/tests/storage.rs b/evm-template/runtime/tests/storage.rs index 6feeb92..d3d9af7 100644 --- a/evm-template/runtime/tests/storage.rs +++ b/evm-template/runtime/tests/storage.rs @@ -1,8 +1,9 @@ // Storage indices integration checks +#[cfg(not(feature = "tanssi"))] +use evm_runtime_template::{Aura, AuraExt, Authorship, CollatorSelection, Session}; use evm_runtime_template::{ - Aura, AuraExt, Authorship, Balances, CollatorSelection, CumulusXcm, MessageQueue, Multisig, - ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, Runtime, Session, Sudo, System, Timestamp, - TransactionPayment, XcmpQueue, + Balances, CumulusXcm, MessageQueue, Multisig, ParachainInfo, ParachainSystem, PolkadotXcm, + Proxy, Runtime, Sudo, System, Timestamp, TransactionPayment, XcmpQueue, }; use frame_support::traits::PalletInfo; @@ -21,13 +22,17 @@ fn verify_pallet_prefixes() { assert_pallet_prefix::("TransactionPayment"); assert_pallet_prefix::("Sudo"); assert_pallet_prefix::("Multisig"); - assert_pallet_prefix::("Authorship"); - assert_pallet_prefix::("CollatorSelection"); - assert_pallet_prefix::("Session"); - assert_pallet_prefix::("Aura"); - assert_pallet_prefix::("AuraExt"); assert_pallet_prefix::("XcmpQueue"); assert_pallet_prefix::("PolkadotXcm"); assert_pallet_prefix::("CumulusXcm"); assert_pallet_prefix::("MessageQueue"); + + #[cfg(not(feature = "tanssi"))] + { + assert_pallet_prefix::("Authorship"); + assert_pallet_prefix::("CollatorSelection"); + assert_pallet_prefix::("Session"); + assert_pallet_prefix::("Aura"); + assert_pallet_prefix::("AuraExt"); + } } diff --git a/generic-template/runtime/src/configs/mod.rs b/generic-template/runtime/src/configs/mod.rs index aa6d598..fc12c45 100644 --- a/generic-template/runtime/src/configs/mod.rs +++ b/generic-template/runtime/src/configs/mod.rs @@ -189,6 +189,11 @@ impl AssetsConfig for OpenZeppelinRuntime { type ForeignAssetModifierOrigin = EnsureRoot; type WeightToFee = WeightToFee; } +#[cfg(feature = "tanssi")] +impl TanssiConfig for OpenZeppelinRuntime { + type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight; + type AuthoritiesNothing = pallet_cc_authorities_noting::weights::SubstrateWeight; +} impl_openzeppelin_system!(OpenZeppelinRuntime); #[cfg(not(feature = "tanssi"))] impl_openzeppelin_consensus!(OpenZeppelinRuntime); @@ -197,4 +202,4 @@ impl_openzeppelin_xcm!(OpenZeppelinRuntime); impl_openzeppelin_assets!(OpenZeppelinRuntime); #[cfg(feature = "tanssi")] -impl_openzeppelin_tanssi!(); +impl_openzeppelin_tanssi!(OpenZeppelinRuntime); diff --git a/generic-template/runtime/src/types.rs b/generic-template/runtime/src/types.rs index 3946a1c..61a1088 100644 --- a/generic-template/runtime/src/types.rs +++ b/generic-template/runtime/src/types.rs @@ -207,6 +207,7 @@ mod test { use crate::{types::ProxyType, AssetManager, RuntimeCall}; #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_any() { let call = RuntimeCall::CollatorSelection( pallet_collator_selection::Call::set_desired_candidates { max: 10 }, @@ -216,6 +217,7 @@ mod test { } #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_nontransfer() { let proxy_type = ProxyType::NonTransfer; let valid_call = RuntimeCall::CollatorSelection( @@ -228,6 +230,7 @@ mod test { } #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_cancel_proxy() { let proxy_type = ProxyType::CancelProxy; let invalid_call = RuntimeCall::CollatorSelection( @@ -242,6 +245,7 @@ mod test { } #[test] + #[cfg(not(feature = "tanssi"))] fn test_filter_collator() { let proxy_type = ProxyType::Collator; let valid_call = RuntimeCall::CollatorSelection( diff --git a/generic-template/runtime/tests/constants_test.rs b/generic-template/runtime/tests/constants_test.rs index dd59d22..67774a3 100644 --- a/generic-template/runtime/tests/constants_test.rs +++ b/generic-template/runtime/tests/constants_test.rs @@ -204,6 +204,7 @@ mod runtime_tests { } #[test] + #[cfg(not(feature = "tanssi"))] fn session_constants() { assert_eq!(configs::Period::get(), 6 * HOURS); @@ -212,6 +213,7 @@ mod runtime_tests { #[test] #[allow(clippy::assertions_on_constants)] + #[cfg(not(feature = "tanssi"))] fn aura_constants() { #[cfg(not(feature = "async-backing"))] assert!(!::AllowMultipleBlocksPerSlot::get()); @@ -222,6 +224,7 @@ mod runtime_tests { } #[test] + #[cfg(not(feature = "tanssi"))] fn collator_selection_constants() { let pallet_id_to_string = |id: PalletId| -> String { core::str::from_utf8(&id.0).unwrap_or_default().to_string() diff --git a/generic-template/runtime/tests/storage.rs b/generic-template/runtime/tests/storage.rs index d3a3aa3..2d771f1 100644 --- a/generic-template/runtime/tests/storage.rs +++ b/generic-template/runtime/tests/storage.rs @@ -1,9 +1,10 @@ // Storage indices integration checks use frame_support::traits::PalletInfo; +#[cfg(not(feature = "tanssi"))] +use generic_runtime_template::{Aura, AuraExt, Authorship, CollatorSelection, Session}; use generic_runtime_template::{ - Aura, AuraExt, Authorship, Balances, CollatorSelection, CumulusXcm, MessageQueue, Multisig, - ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, Runtime, Session, Sudo, System, Timestamp, - TransactionPayment, XcmpQueue, + Balances, CumulusXcm, MessageQueue, Multisig, ParachainInfo, ParachainSystem, PolkadotXcm, + Proxy, Runtime, Sudo, System, Timestamp, TransactionPayment, XcmpQueue, }; fn assert_pallet_prefix(name: &str) { @@ -21,13 +22,17 @@ fn verify_pallet_prefixes() { assert_pallet_prefix::("TransactionPayment"); assert_pallet_prefix::("Sudo"); assert_pallet_prefix::("Multisig"); - assert_pallet_prefix::("Authorship"); - assert_pallet_prefix::("CollatorSelection"); - assert_pallet_prefix::("Session"); - assert_pallet_prefix::("Aura"); - assert_pallet_prefix::("AuraExt"); assert_pallet_prefix::("XcmpQueue"); assert_pallet_prefix::("PolkadotXcm"); assert_pallet_prefix::("CumulusXcm"); assert_pallet_prefix::("MessageQueue"); + + #[cfg(not(feature = "tanssi"))] + { + assert_pallet_prefix::("Authorship"); + assert_pallet_prefix::("Aura"); + assert_pallet_prefix::("AuraExt"); + assert_pallet_prefix::("CollatorSelection"); + assert_pallet_prefix::("Session"); + } }