mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Implements pallet versioning (#7208)
* Start * Make macro work * Rename `ModuleToIndex` to `PalletRuntimeSetup` Besides the renaming it also adds support getting the name of a pallet as configured in the runtime. * Rename it to `PalletInfo` * Remove accidentally added files * Some work * Make everything compile * Adds a test and fixes some bugs * Implement ordering for `PalletVersion` * Apply suggestions from code review * Review feedback * Update frame/support/src/dispatch.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/support/src/dispatch.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fix compilation * Fix test * Fix doc test Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -22,16 +22,12 @@ mod tests {
|
||||
use frame_support::metadata::*;
|
||||
use sp_io::TestExternalities;
|
||||
use std::marker::PhantomData;
|
||||
use codec::{Encode, Decode, EncodeLike};
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
pub trait Trait {
|
||||
type Origin: Encode + Decode + EncodeLike + std::default::Default;
|
||||
type BlockNumber;
|
||||
}
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as TestStorage {
|
||||
@@ -74,7 +70,7 @@ mod tests {
|
||||
pub PUBGETMAPU32MYDEF get(fn pub_map_u32_getter_mydef):
|
||||
map hasher(blake2_128_concat) u32 => String = "pubmap".into();
|
||||
|
||||
COMPLEXTYPE1: ::std::vec::Vec<<T as Trait>::Origin>;
|
||||
COMPLEXTYPE1: ::std::vec::Vec<T::Origin>;
|
||||
COMPLEXTYPE2: (Vec<Vec<(u16, Box<()>)>>, u32);
|
||||
COMPLEXTYPE3: [u32; 25];
|
||||
}
|
||||
@@ -85,11 +81,15 @@ mod tests {
|
||||
|
||||
struct TraitImpl {}
|
||||
|
||||
impl Trait for TraitImpl {
|
||||
impl frame_support_test::Trait for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {}
|
||||
|
||||
const EXPECTED_METADATA: StorageMetadata = StorageMetadata {
|
||||
prefix: DecodeDifferent::Encode("TestStorage"),
|
||||
entries: DecodeDifferent::Encode(
|
||||
@@ -353,7 +353,7 @@ mod tests {
|
||||
StorageEntryMetadata {
|
||||
name: DecodeDifferent::Encode("COMPLEXTYPE1"),
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("::std::vec::Vec<<T as Trait>::Origin>")),
|
||||
ty: StorageEntryType::Plain(DecodeDifferent::Encode("::std::vec::Vec<T::Origin>")),
|
||||
default: DecodeDifferent::Encode(
|
||||
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE1(PhantomData::<TraitImpl>))
|
||||
),
|
||||
@@ -414,13 +414,10 @@ mod tests {
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
mod test2 {
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
}
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
type PairOf<T> = (T, T);
|
||||
@@ -441,21 +438,23 @@ mod test2 {
|
||||
|
||||
struct TraitImpl {}
|
||||
|
||||
impl Trait for TraitImpl {
|
||||
impl frame_support_test::Trait for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
mod test3 {
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
}
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
@@ -467,10 +466,14 @@ mod test3 {
|
||||
|
||||
struct TraitImpl {}
|
||||
|
||||
impl Trait for TraitImpl {
|
||||
impl frame_support_test::Trait for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -479,13 +482,10 @@ mod test_append_and_len {
|
||||
use sp_io::TestExternalities;
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
}
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
@@ -511,11 +511,15 @@ mod test_append_and_len {
|
||||
|
||||
struct Test {}
|
||||
|
||||
impl Trait for Test {
|
||||
impl frame_support_test::Trait for Test {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for Test {}
|
||||
|
||||
#[test]
|
||||
fn default_for_option() {
|
||||
TestExternalities::default().execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user