mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Replace last usages of <() as PalletInfo> in substrate (#8080)
* replace last occurences * Update frame/support/src/traits.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/support/test/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * fix dispatch test * move PanicPalletInfo to tests module Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
1ee71e54e5
commit
9fbbecc195
@@ -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 = ();
|
||||
|
||||
@@ -1074,7 +1074,7 @@ mod tests {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = pallet_balances::AccountData<u64>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
|
||||
@@ -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<u64>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
|
||||
@@ -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<u64>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
|
||||
@@ -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<u64>;
|
||||
|
||||
@@ -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<u32> { }
|
||||
@@ -2562,13 +2562,32 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl PalletInfo for TraitImpl {
|
||||
fn index<P: 'static>() -> Option<usize> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<Test>() {
|
||||
return Some(0)
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
fn name<P: 'static>() -> Option<&'static str> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<Test>() {
|
||||
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 = ();
|
||||
type PalletInfo = Self;
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -729,7 +729,7 @@ mod tests {
|
||||
impl system::Config for TestRuntime {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
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 = ();
|
||||
type PalletInfo = crate::tests::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl system::Config for TestRuntime2 {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = crate::tests::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<P: 'static>() -> Option<usize> {
|
||||
unimplemented!("PanicPalletInfo mustn't be triggered by tests");
|
||||
}
|
||||
fn name<P: 'static>() -> 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 = ();
|
||||
type PalletInfo = PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<P: 'static>() -> Option<usize> { unimplemented!() }
|
||||
///# fn name<P: 'static>() -> 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<P: 'static>() -> Option<usize> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<system::Module<TestRuntime>>() {
|
||||
return Some(0)
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<EventModule>() {
|
||||
return Some(1)
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<EventModule2>() {
|
||||
return Some(2)
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
fn name<P: 'static>() -> Option<&'static str> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<system::Module<TestRuntime>>() {
|
||||
return Some("System")
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<EventModule>() {
|
||||
return Some("EventModule")
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<EventModule2>() {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
impl Config for Runtime {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = crate::tests::PanicPalletInfo;
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -841,7 +841,7 @@ mod tests {
|
||||
type BlockNumber = u32;
|
||||
type Balance = u32;
|
||||
type DbWeight = DbWeight;
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = crate::tests::PanicPalletInfo;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
|
||||
@@ -41,3 +41,15 @@ frame_support::decl_module! {
|
||||
/// Some test module
|
||||
pub struct Module<T: Config> 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<P: 'static>() -> Option<usize> {
|
||||
unimplemented!("PanicPalletInfo mustn't be triggered by tests");
|
||||
}
|
||||
fn name<P: 'static>() -> Option<&'static str> {
|
||||
unimplemented!("PanicPalletInfo mustn't be triggered by tests");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = ();
|
||||
}
|
||||
|
||||
@@ -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 = ();
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ mod tests {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type Version = ();
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = ();
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
|
||||
@@ -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 = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -681,7 +681,7 @@ mod tests {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = pallet_balances::AccountData<u64>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
|
||||
@@ -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<u64>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
|
||||
@@ -433,6 +433,37 @@ impl From<frame_system::Event<Runtime>> for Event {
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_support::traits::PalletInfo for Runtime {
|
||||
fn index<P: 'static>() -> Option<usize> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<system::Module<Runtime>>() {
|
||||
return Some(0)
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<pallet_timestamp::Module<Runtime>>() {
|
||||
return Some(1)
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<pallet_babe::Module<Runtime>>() {
|
||||
return Some(2)
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
fn name<P: 'static>() -> Option<&'static str> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<system::Module<Runtime>>() {
|
||||
return Some("System")
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<pallet_timestamp::Module<Runtime>>() {
|
||||
return Some("Timestamp")
|
||||
}
|
||||
if type_id == sp_std::any::TypeId::of::<pallet_babe::Module<Runtime>>() {
|
||||
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 = ();
|
||||
|
||||
Reference in New Issue
Block a user