From 74f1f85c7d832087a3e9f8d25e98999b64908e59 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Tue, 9 Feb 2021 11:31:10 +0100 Subject: [PATCH 1/5] replace last occurences --- frame/collective/src/lib.rs | 2 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/elections/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/society/src/mock.rs | 2 +- frame/support/src/dispatch.rs | 4 +- frame/support/src/event.rs | 6 +-- frame/support/src/lib.rs | 2 +- frame/support/src/metadata.rs | 39 ++++++++++++++++++- frame/support/src/storage/generator/mod.rs | 2 +- frame/support/src/traits.rs | 14 +++++++ frame/support/src/weights.rs | 2 +- frame/support/test/src/lib.rs | 12 ++++++ frame/support/test/tests/decl_storage.rs | 8 ++-- frame/support/test/tests/genesisconfig.rs | 2 +- frame/support/test/tests/instance.rs | 2 +- frame/support/test/tests/issue2219.rs | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 2 +- .../support/test/tests/storage_transaction.rs | 2 +- frame/transaction-payment/src/lib.rs | 2 +- frame/utility/src/tests.rs | 2 +- test-utils/runtime/src/lib.rs | 33 +++++++++++++++- 22 files changed, 119 insertions(+), 27 deletions(-) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index ead9135aaa19f..50beb8607d61d 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -995,7 +995,7 @@ mod tests { type Event = Event; type BlockHashCount = BlockHashCount; type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index d566975e2e7a9..057e9f181c7af 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1074,7 +1074,7 @@ mod tests { type Event = Event; type BlockHashCount = BlockHashCount; type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index b386542b2b3db..7c9bc9bfaf8b0 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Test { type Event = Event; type BlockHashCount = BlockHashCount; type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 5d6d13aa30913..e4ec32d0bc3bf 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type Event = Event; type BlockHashCount = (); type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 8c39a0bc3ea59..4b1bb21dd18db 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -83,7 +83,7 @@ impl frame_system::Config for Test { type Event = Event; type BlockHashCount = BlockHashCount; type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type OnNewAccount = (); type OnKilledAccount = (); type AccountData = pallet_balances::AccountData; diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 03cda0e4d40e0..1ded92d43be94 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2409,7 +2409,7 @@ mod tests { use crate::weights::{DispatchInfo, DispatchClass, Pays, RuntimeDbWeight}; use crate::traits::{ CallMetadata, GetCallMetadata, GetCallName, OnInitialize, OnFinalize, OnRuntimeUpgrade, - IntegrityTest, Get, + IntegrityTest, Get, PalletInfo, }; pub trait Config: system::Config + Sized where Self::AccountId: From { } @@ -2568,7 +2568,7 @@ mod tests { type Call = OuterCall; type BaseCallFilter = (); type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = crate::traits::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index 39baee29bc0cd..c8148db369bca 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -729,7 +729,7 @@ mod tests { impl system::Config for TestRuntime { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = crate::traits::PanicPalletInfo; type DbWeight = (); } @@ -744,14 +744,14 @@ mod tests { impl system_renamed::Config for TestRuntime2 { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = crate::traits::PanicPalletInfo; type DbWeight = (); } impl system::Config for TestRuntime2 { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = crate::traits::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 951e12c9c7d4a..f42c06878438e 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -625,7 +625,7 @@ mod tests { impl Config for Test { type BlockNumber = u32; type Origin = u32; - type PalletInfo = (); + type PalletInfo = crate::traits::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/src/metadata.rs b/frame/support/src/metadata.rs index a60481933701b..2edaba1cb47e9 100644 --- a/frame/support/src/metadata.rs +++ b/frame/support/src/metadata.rs @@ -43,10 +43,14 @@ pub use frame_metadata::{ ///# } ///# use module0 as module1; ///# use module0 as module2; +///# impl frame_support::traits::PalletInfo for Runtime { +///# fn index() -> Option { unimplemented!() } +///# fn name() -> Option<&'static str> { unimplemented!() } +///# } ///# impl module0::Config for Runtime { ///# type Origin = u32; ///# type BlockNumber = u32; -///# type PalletInfo = (); +///# type PalletInfo = Self; ///# type DbWeight = (); ///# } ///# @@ -414,6 +418,37 @@ mod tests { #[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub struct TestRuntime; + impl crate::traits::PalletInfo for TestRuntime { + fn index() -> Option { + let type_id = sp_std::any::TypeId::of::

(); + if type_id == sp_std::any::TypeId::of::>() { + return Some(0) + } + if type_id == sp_std::any::TypeId::of::() { + return Some(1) + } + if type_id == sp_std::any::TypeId::of::() { + return Some(2) + } + + None + } + fn name() -> Option<&'static str> { + let type_id = sp_std::any::TypeId::of::

(); + if type_id == sp_std::any::TypeId::of::>() { + return Some("System") + } + if type_id == sp_std::any::TypeId::of::() { + return Some("EventModule") + } + if type_id == sp_std::any::TypeId::of::() { + return Some("EventModule2") + } + + None + } + } + impl_outer_event! { pub enum TestEvent for TestRuntime { system, @@ -451,7 +486,7 @@ mod tests { type AccountId = u32; type BlockNumber = u32; type SomeValue = SystemValue; - type PalletInfo = (); + type PalletInfo = Self; type DbWeight = (); type Call = Call; } diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index a9e5665c544d2..683560540d804 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -52,7 +52,7 @@ mod tests { impl Config for Runtime { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = crate::traits::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index c52aa60c20b15..1558536eb08d0 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -1464,6 +1464,20 @@ impl PalletInfo for () { fn name() -> Option<&'static str> { Some("test") } } +/// A PalletInfo implementation which just panics +#[cfg(test)] +pub struct PanicPalletInfo; + +#[cfg(test)] +impl PalletInfo for PanicPalletInfo{ + fn index() -> Option { + unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + } + fn name() -> Option<&'static str> { + unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + } +} + /// The function and pallet name of the Call. #[derive(Clone, Eq, PartialEq, Default, RuntimeDebug)] pub struct CallMetadata { diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index 32dc9e1f2529f..210e057ae805e 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -841,7 +841,7 @@ mod tests { type BlockNumber = u32; type Balance = u32; type DbWeight = DbWeight; - type PalletInfo = (); + type PalletInfo = crate::traits::PanicPalletInfo; } decl_module! { diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index d837056fe6ab6..276c7a29db8b0 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -41,3 +41,15 @@ frame_support::decl_module! { /// Some test module pub struct Module for enum Call where origin: T::Origin, system=self {} } + +/// A PalletInfo implementation which just panics +pub struct PanicPalletInfo; + +impl frame_support::traits::PalletInfo for PanicPalletInfo{ + fn index() -> Option { + unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + } + fn name() -> Option<&'static str> { + unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + } +} diff --git a/frame/support/test/tests/decl_storage.rs b/frame/support/test/tests/decl_storage.rs index 99697393785fe..a2690b1379db5 100644 --- a/frame/support/test/tests/decl_storage.rs +++ b/frame/support/test/tests/decl_storage.rs @@ -84,7 +84,7 @@ mod tests { impl frame_support_test::Config for TraitImpl { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = frame_support_test::PanicPalletInfo; type DbWeight = (); } @@ -441,7 +441,7 @@ mod test2 { impl frame_support_test::Config for TraitImpl { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = frame_support_test::PanicPalletInfo; type DbWeight = (); } @@ -469,7 +469,7 @@ mod test3 { impl frame_support_test::Config for TraitImpl { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = frame_support_test::PanicPalletInfo; type DbWeight = (); } @@ -514,7 +514,7 @@ mod test_append_and_len { impl frame_support_test::Config for Test { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = frame_support_test::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index dd98fca8c9538..a30b021d13e51 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -32,7 +32,7 @@ struct Test; impl frame_support_test::Config for Test { type BlockNumber = u32; type Origin = (); - type PalletInfo = (); + type PalletInfo = frame_support_test::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index dc6c41564a753..f7d79b7d4bf6e 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -253,7 +253,7 @@ impl system::Config for Runtime { type BlockNumber = BlockNumber; type AccountId = AccountId; type Event = Event; - type PalletInfo = (); + type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); } diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index adabb2d597928..4eacca9daca01 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -164,7 +164,7 @@ impl system::Config for Runtime { type BlockNumber = BlockNumber; type AccountId = AccountId; type Event = Event; - type PalletInfo = (); + type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); } diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 6247e46c85f01..b09beb04cd17c 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -135,7 +135,7 @@ mod tests { type BlockWeights = (); type BlockLength = (); type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index ee6ce5869e176..b518c60e957c6 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -53,7 +53,7 @@ struct Runtime; impl frame_support_test::Config for Runtime { type Origin = u32; type BlockNumber = u32; - type PalletInfo = (); + type PalletInfo = frame_support_test::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 5f907fb91b99e..c460fcba3a597 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -681,7 +681,7 @@ mod tests { type Event = Event; type BlockHashCount = BlockHashCount; type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index b14f958bd6f8d..af31bbe96cbc4 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -104,7 +104,7 @@ impl frame_system::Config for Test { type Event = Event; type BlockHashCount = BlockHashCount; type Version = (); - type PalletInfo = (); + type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index d7d7ccd31b713..b349d1266b031 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -433,6 +433,37 @@ impl From> for Event { } } +impl frame_support::traits::PalletInfo for Runtime { + fn index() -> Option { + let type_id = sp_std::any::TypeId::of::

(); + if type_id == sp_std::any::TypeId::of::>() { + return Some(0) + } + if type_id == sp_std::any::TypeId::of::>() { + return Some(1) + } + if type_id == sp_std::any::TypeId::of::>() { + return Some(2) + } + + None + } + fn name() -> Option<&'static str> { + let type_id = sp_std::any::TypeId::of::

(); + if type_id == sp_std::any::TypeId::of::>() { + return Some("System") + } + if type_id == sp_std::any::TypeId::of::>() { + return Some("Timestamp") + } + if type_id == sp_std::any::TypeId::of::>() { + return Some("Babe") + } + + None + } +} + parameter_types! { pub const BlockHashCount: BlockNumber = 2400; pub const MinimumPeriod: u64 = 5; @@ -463,7 +494,7 @@ impl frame_system::Config for Runtime { type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); - type PalletInfo = (); + type PalletInfo = Self; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); From b1068b5b8edf29405ebcb6bdc55670264ef42a50 Mon Sep 17 00:00:00 2001 From: Guillaume Thiolliere Date: Tue, 9 Feb 2021 12:19:40 +0100 Subject: [PATCH 2/5] Update frame/support/src/traits.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/support/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 1558536eb08d0..acf0e2d615ed7 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -1464,7 +1464,7 @@ impl PalletInfo for () { fn name() -> Option<&'static str> { Some("test") } } -/// A PalletInfo implementation which just panics +/// A PalletInfo implementation which just panics. #[cfg(test)] pub struct PanicPalletInfo; From 5cf931bab082c844240fdaa1f311a4de7ecf7138 Mon Sep 17 00:00:00 2001 From: Guillaume Thiolliere Date: Tue, 9 Feb 2021 12:19:45 +0100 Subject: [PATCH 3/5] Update frame/support/test/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/support/test/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index 276c7a29db8b0..744908d037c74 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -42,7 +42,7 @@ frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin, system=self {} } -/// A PalletInfo implementation which just panics +/// A PalletInfo implementation which just panics. pub struct PanicPalletInfo; impl frame_support::traits::PalletInfo for PanicPalletInfo{ From be73273b0aec61caeb98f12cc2aa4c9997dc4f5d Mon Sep 17 00:00:00 2001 From: thiolliere Date: Tue, 9 Feb 2021 13:06:11 +0100 Subject: [PATCH 4/5] fix dispatch test --- frame/support/src/dispatch.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 1ded92d43be94..7927ccd014bd5 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2562,13 +2562,32 @@ mod tests { } } + impl PalletInfo for TraitImpl { + fn index() -> Option { + let type_id = sp_std::any::TypeId::of::

(); + if type_id == sp_std::any::TypeId::of::() { + return Some(0) + } + + None + } + fn name() -> Option<&'static str> { + let type_id = sp_std::any::TypeId::of::

(); + if type_id == sp_std::any::TypeId::of::() { + return Some("Test") + } + + None + } + } + impl system::Config for TraitImpl { type Origin = OuterOrigin; type AccountId = u32; type Call = OuterCall; type BaseCallFilter = (); type BlockNumber = u32; - type PalletInfo = crate::traits::PanicPalletInfo; + type PalletInfo = Self; type DbWeight = (); } From dbb5d94eafa5092a10ab6ff6bd38c9d72eb23825 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Tue, 9 Feb 2021 15:56:37 +0100 Subject: [PATCH 5/5] move PanicPalletInfo to tests module --- frame/support/src/event.rs | 6 +++--- frame/support/src/lib.rs | 16 ++++++++++++++-- frame/support/src/storage/generator/mod.rs | 2 +- frame/support/src/traits.rs | 14 -------------- frame/support/src/weights.rs | 2 +- frame/support/test/src/lib.rs | 2 +- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index c8148db369bca..eb666b6f028ab 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -729,7 +729,7 @@ mod tests { impl system::Config for TestRuntime { type Origin = u32; type BlockNumber = u32; - type PalletInfo = crate::traits::PanicPalletInfo; + type PalletInfo = crate::tests::PanicPalletInfo; type DbWeight = (); } @@ -744,14 +744,14 @@ mod tests { impl system_renamed::Config for TestRuntime2 { type Origin = u32; type BlockNumber = u32; - type PalletInfo = crate::traits::PanicPalletInfo; + type PalletInfo = crate::tests::PanicPalletInfo; type DbWeight = (); } impl system::Config for TestRuntime2 { type Origin = u32; type BlockNumber = u32; - type PalletInfo = crate::traits::PanicPalletInfo; + type PalletInfo = crate::tests::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index f42c06878438e..940e70852af52 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -571,7 +571,7 @@ macro_rules! assert_ok { pub use serde::{Serialize, Deserialize}; #[cfg(test)] -mod tests { +pub mod tests { use super::*; use codec::{Codec, EncodeLike}; use frame_metadata::{ @@ -581,6 +581,18 @@ mod tests { use sp_std::{marker::PhantomData, result}; use sp_io::TestExternalities; + /// A PalletInfo implementation which just panics. + pub struct PanicPalletInfo; + + impl crate::traits::PalletInfo for PanicPalletInfo { + fn index() -> Option { + unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + } + fn name() -> Option<&'static str> { + unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + } + } + pub trait Config: 'static { type BlockNumber: Codec + EncodeLike + Default; type Origin; @@ -625,7 +637,7 @@ mod tests { impl Config for Test { type BlockNumber = u32; type Origin = u32; - type PalletInfo = crate::traits::PanicPalletInfo; + type PalletInfo = PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index 683560540d804..fc2a21ff72517 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -52,7 +52,7 @@ mod tests { impl Config for Runtime { type Origin = u32; type BlockNumber = u32; - type PalletInfo = crate::traits::PanicPalletInfo; + type PalletInfo = crate::tests::PanicPalletInfo; type DbWeight = (); } diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index acf0e2d615ed7..c52aa60c20b15 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -1464,20 +1464,6 @@ impl PalletInfo for () { fn name() -> Option<&'static str> { Some("test") } } -/// A PalletInfo implementation which just panics. -#[cfg(test)] -pub struct PanicPalletInfo; - -#[cfg(test)] -impl PalletInfo for PanicPalletInfo{ - fn index() -> Option { - unimplemented!("PanicPalletInfo mustn't be triggered by tests"); - } - fn name() -> Option<&'static str> { - unimplemented!("PanicPalletInfo mustn't be triggered by tests"); - } -} - /// The function and pallet name of the Call. #[derive(Clone, Eq, PartialEq, Default, RuntimeDebug)] pub struct CallMetadata { diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index 210e057ae805e..abd54994bc9e8 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -841,7 +841,7 @@ mod tests { type BlockNumber = u32; type Balance = u32; type DbWeight = DbWeight; - type PalletInfo = crate::traits::PanicPalletInfo; + type PalletInfo = crate::tests::PanicPalletInfo; } decl_module! { diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index 744908d037c74..4b1510bf81f4d 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -45,7 +45,7 @@ frame_support::decl_module! { /// A PalletInfo implementation which just panics. pub struct PanicPalletInfo; -impl frame_support::traits::PalletInfo for PanicPalletInfo{ +impl frame_support::traits::PalletInfo for PanicPalletInfo { fn index() -> Option { unimplemented!("PanicPalletInfo mustn't be triggered by tests"); }