mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 21:51:06 +00:00
Add MaxEncodeLen to implement_per_thing! (#10715)
* fix doc Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add MaxEncodedLen to implement_per_thing! Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test that Percent et.al. can be used in Storage. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add comment Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Test that Percent et.al. can be used in Storage." This reverts commit 52558afea6f9b53fb07521f1b6393bc320d21dfc. * Test MaxEncodedLen in implement_per_thing! Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Add comment" This reverts commit 27a96f6e527f71a57ace289c041de514edbe9104.
This commit is contained in:
committed by
GitHub
parent
f41ef340e5
commit
4880741eaa
@@ -432,7 +432,7 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test that a pallet with non generic event and generic genesis_config is correctly handled
|
// Test that a pallet with non generic event and generic genesis_config is correctly handled
|
||||||
// and that a pallet without the attribute generate_storage_info is correctly handled.
|
// and that a pallet with the attribute without_storage_info is correctly handled.
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet2 {
|
pub mod pallet2 {
|
||||||
use super::{SomeAssociation1, SomeType1};
|
use super::{SomeAssociation1, SomeType1};
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ macro_rules! implement_per_thing {
|
|||||||
///
|
///
|
||||||
#[doc = $title]
|
#[doc = $title]
|
||||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||||
#[derive(Encode, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, scale_info::TypeInfo)]
|
#[derive(Encode, Copy, Clone, PartialEq, Eq, codec::MaxEncodedLen, PartialOrd, Ord, RuntimeDebug, scale_info::TypeInfo)]
|
||||||
pub struct $name($type);
|
pub struct $name($type);
|
||||||
|
|
||||||
/// Implementation makes any compact encoding of `PerThing::Inner` valid,
|
/// Implementation makes any compact encoding of `PerThing::Inner` valid,
|
||||||
@@ -905,6 +905,15 @@ macro_rules! implement_per_thing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn has_max_encoded_len() {
|
||||||
|
struct AsMaxEncodedLen<T: codec::MaxEncodedLen> {
|
||||||
|
_data: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = AsMaxEncodedLen { _data: $name(1) };
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fail_on_invalid_encoded_value() {
|
fn fail_on_invalid_encoded_value() {
|
||||||
let value = <$upper_type>::from($max) * 2;
|
let value = <$upper_type>::from($max) * 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user