Skip to content

Commit

Permalink
fix the tanssi build & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KitHat committed Dec 27, 2024
1 parent 9158633 commit a32b7a0
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 22 deletions.
9 changes: 6 additions & 3 deletions evm-template/runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ impl SystemConfig for OpenZeppelinRuntime {
type SlotDuration = ConstU64<SLOT_DURATION>;
type Version = Version;
}
#[cfg(feature = "tanssi")]
impl TanssiConfig for OpenZeppelinRuntime {}
#[cfg(not(feature = "tanssi"))]
impl ConsensusConfig for OpenZeppelinRuntime {
type CollatorSelectionUpdateOrigin = CollatorSelectionUpdateOrigin;
Expand Down Expand Up @@ -215,12 +213,17 @@ impl AssetsConfig for OpenZeppelinRuntime {
type ForeignAssetModifierOrigin = EnsureRoot<AccountId>;
type WeightToFee = WeightToFee;
}
#[cfg(feature = "tanssi")]
impl TanssiConfig for OpenZeppelinRuntime {
type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight<Runtime>;
type AuthoritiesNothing = pallet_cc_authorities_noting::weights::SubstrateWeight<Runtime>;
}
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);
Expand Down
4 changes: 4 additions & 0 deletions evm-template/runtime/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions evm-template/runtime/tests/constants_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ mod runtime_tests {
}

#[test]
#[cfg(not(feature = "tanssi"))]
fn session_constants() {
assert_eq!(configs::Period::get(), 6 * HOURS);

Expand All @@ -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!(!<Runtime as pallet_aura::Config>::AllowMultipleBlocksPerSlot::get());
Expand All @@ -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()
Expand Down
21 changes: 13 additions & 8 deletions evm-template/runtime/tests/storage.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -21,13 +22,17 @@ fn verify_pallet_prefixes() {
assert_pallet_prefix::<TransactionPayment>("TransactionPayment");
assert_pallet_prefix::<Sudo>("Sudo");
assert_pallet_prefix::<Multisig>("Multisig");
assert_pallet_prefix::<Authorship>("Authorship");
assert_pallet_prefix::<CollatorSelection>("CollatorSelection");
assert_pallet_prefix::<Session>("Session");
assert_pallet_prefix::<Aura>("Aura");
assert_pallet_prefix::<AuraExt>("AuraExt");
assert_pallet_prefix::<XcmpQueue>("XcmpQueue");
assert_pallet_prefix::<PolkadotXcm>("PolkadotXcm");
assert_pallet_prefix::<CumulusXcm>("CumulusXcm");
assert_pallet_prefix::<MessageQueue>("MessageQueue");

#[cfg(not(feature = "tanssi"))]
{
assert_pallet_prefix::<Authorship>("Authorship");
assert_pallet_prefix::<CollatorSelection>("CollatorSelection");
assert_pallet_prefix::<Session>("Session");
assert_pallet_prefix::<Aura>("Aura");
assert_pallet_prefix::<AuraExt>("AuraExt");
}
}
11 changes: 7 additions & 4 deletions generic-template/runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ use frame_system::{
pub use governance::origins::pallet_custom_origins;

Check warning on line 31 in generic-template/runtime/src/configs/mod.rs

View workflow job for this annotation

GitHub Actions / clippy-fmt-test (ubuntu-22.04, false)

Diff in /home/runner/work/polkadot-runtime-templates/polkadot-runtime-templates/generic-template/runtime/src/configs/mod.rs
use governance::{origins::Treasurer, tracks, Spender, WhitelistedCaller};
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_assets, impl_openzeppelin_governance, impl_openzeppelin_system,
impl_openzeppelin_xcm, AssetsConfig, AssetsWeight, GovernanceConfig, GovernanceWeight,
SystemConfig, SystemWeight, XcmConfig, XcmWeight,
impl_openzeppelin_assets, impl_openzeppelin_governance, impl_openzeppelin_system, impl_openzeppelin_xcm, AssetsConfig, AssetsWeight, GovernanceConfig, GovernanceWeight, SystemConfig, SystemWeight, XcmConfig, XcmWeight
};
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::{
Expand Down Expand Up @@ -189,6 +187,11 @@ impl AssetsConfig for OpenZeppelinRuntime {
type ForeignAssetModifierOrigin = EnsureRoot<AccountId>;

Check warning on line 187 in generic-template/runtime/src/configs/mod.rs

View workflow job for this annotation

GitHub Actions / clippy-fmt-test (ubuntu-22.04, false)

Diff in /home/runner/work/polkadot-runtime-templates/polkadot-runtime-templates/generic-template/runtime/src/configs/mod.rs
type WeightToFee = WeightToFee;
}
#[cfg(feature="tanssi")]
impl TanssiConfig for OpenZeppelinRuntime {
type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight<Runtime>;
type AuthoritiesNothing = pallet_cc_authorities_noting::weights::SubstrateWeight<Runtime>;
}
impl_openzeppelin_system!(OpenZeppelinRuntime);
#[cfg(not(feature = "tanssi"))]
impl_openzeppelin_consensus!(OpenZeppelinRuntime);
Expand All @@ -197,4 +200,4 @@ impl_openzeppelin_xcm!(OpenZeppelinRuntime);
impl_openzeppelin_assets!(OpenZeppelinRuntime);

#[cfg(feature = "tanssi")]
impl_openzeppelin_tanssi!();
impl_openzeppelin_tanssi!(OpenZeppelinRuntime);
4 changes: 4 additions & 0 deletions generic-template/runtime/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions generic-template/runtime/tests/constants_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ mod runtime_tests {
}

#[test]
#[cfg(not(feature = "tanssi"))]
fn session_constants() {
assert_eq!(configs::Period::get(), 6 * HOURS);

Expand All @@ -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!(!<Runtime as pallet_aura::Config>::AllowMultipleBlocksPerSlot::get());
Expand All @@ -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()
Expand Down
23 changes: 16 additions & 7 deletions generic-template/runtime/tests/storage.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Storage indices integration checks

Check warning on line 1 in generic-template/runtime/tests/storage.rs

View workflow job for this annotation

GitHub Actions / clippy-fmt-test (ubuntu-22.04, false)

Diff in /home/runner/work/polkadot-runtime-templates/polkadot-runtime-templates/generic-template/runtime/tests/storage.rs
use frame_support::traits::PalletInfo;
use generic_runtime_template::{
Aura, AuraExt, Authorship, Balances, CollatorSelection, CumulusXcm, MessageQueue, Multisig,
ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, Runtime, Session, Sudo, System, Timestamp,
Balances, CumulusXcm, MessageQueue, Multisig,
ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, Runtime, Sudo, System, Timestamp,
TransactionPayment, XcmpQueue,
};
#[cfg(not(feature = "tanssi"))]
use generic_runtime_template::{
Aura, AuraExt, Authorship, CollatorSelection, Session
};

fn assert_pallet_prefix<P: 'static>(name: &str) {
assert_eq!(<Runtime as frame_system::Config>::PalletInfo::name::<P>(), Some(name));
Expand All @@ -21,13 +25,18 @@ fn verify_pallet_prefixes() {
assert_pallet_prefix::<TransactionPayment>("TransactionPayment");
assert_pallet_prefix::<Sudo>("Sudo");
assert_pallet_prefix::<Multisig>("Multisig");
assert_pallet_prefix::<Authorship>("Authorship");
assert_pallet_prefix::<CollatorSelection>("CollatorSelection");
assert_pallet_prefix::<Session>("Session");
assert_pallet_prefix::<Aura>("Aura");
assert_pallet_prefix::<AuraExt>("AuraExt");
assert_pallet_prefix::<XcmpQueue>("XcmpQueue");
assert_pallet_prefix::<PolkadotXcm>("PolkadotXcm");

Check warning on line 29 in generic-template/runtime/tests/storage.rs

View workflow job for this annotation

GitHub Actions / clippy-fmt-test (ubuntu-22.04, false)

Diff in /home/runner/work/polkadot-runtime-templates/polkadot-runtime-templates/generic-template/runtime/tests/storage.rs
assert_pallet_prefix::<CumulusXcm>("CumulusXcm");
assert_pallet_prefix::<MessageQueue>("MessageQueue");

#[cfg(not(feature = "tanssi"))]
{

assert_pallet_prefix::<Authorship>("Authorship");
assert_pallet_prefix::<Aura>("Aura");
assert_pallet_prefix::<AuraExt>("AuraExt");
assert_pallet_prefix::<CollatorSelection>("CollatorSelection");
assert_pallet_prefix::<Session>("Session");
}
}

0 comments on commit a32b7a0

Please sign in to comment.