Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
move PanicPalletInfo to tests module
  • Loading branch information
gui1117 committed Feb 9, 2021
commit dbb5d94eafa5092a10ab6ff6bd38c9d72eb23825
6 changes: 3 additions & 3 deletions frame/support/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();
}

Expand All @@ -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 = ();
}

Expand Down
16 changes: 14 additions & 2 deletions frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down Expand Up @@ -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 = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/support/src/storage/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();
}

Expand Down
14 changes: 0 additions & 14 deletions frame/support/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,20 +1464,6 @@ impl PalletInfo for () {
fn name<P: 'static>() -> Option<&'static str> { Some("test") }
}

/// A PalletInfo implementation which just panics.
#[cfg(test)]
pub struct PanicPalletInfo;

#[cfg(test)]
impl 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");
}
}

/// The function and pallet name of the Call.
#[derive(Clone, Eq, PartialEq, Default, RuntimeDebug)]
pub struct CallMetadata {
Expand Down
2 changes: 1 addition & 1 deletion frame/support/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
2 changes: 1 addition & 1 deletion frame/support/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: 'static>() -> Option<usize> {
unimplemented!("PanicPalletInfo mustn't be triggered by tests");
}
Expand Down