Skip to content

Commit cd99081

Browse files
ggwpezgrishasobol
authored andcommitted
Add MaxEncodeLen to implement_per_thing! (paritytech#10715)
* fix doc Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add MaxEncodedLen to implement_per_thing! Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Test that Percent et.al. can be used in Storage. Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add comment Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Revert "Test that Percent et.al. can be used in Storage." This reverts commit 52558af. * Test MaxEncodedLen in implement_per_thing! Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Revert "Add comment" This reverts commit 27a96f6.
1 parent a665475 commit cd99081

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

frame/support/test/tests/pallet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ pub mod pallet {
432432
}
433433

434434
// Test that a pallet with non generic event and generic genesis_config is correctly handled
435-
// and that a pallet without the attribute generate_storage_info is correctly handled.
435+
// and that a pallet with the attribute without_storage_info is correctly handled.
436436
#[frame_support::pallet]
437437
pub mod pallet2 {
438438
use super::{SomeAssociation1, SomeType1};

primitives/arithmetic/src/per_things.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ macro_rules! implement_per_thing {
425425
///
426426
#[doc = $title]
427427
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
428-
#[derive(Encode, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, scale_info::TypeInfo)]
428+
#[derive(Encode, Copy, Clone, PartialEq, Eq, codec::MaxEncodedLen, PartialOrd, Ord, RuntimeDebug, scale_info::TypeInfo)]
429429
pub struct $name($type);
430430

431431
/// Implementation makes any compact encoding of `PerThing::Inner` valid,
@@ -905,6 +905,15 @@ macro_rules! implement_per_thing {
905905
}
906906
}
907907

908+
#[test]
909+
fn has_max_encoded_len() {
910+
struct AsMaxEncodedLen<T: codec::MaxEncodedLen> {
911+
_data: T,
912+
}
913+
914+
let _ = AsMaxEncodedLen { _data: $name(1) };
915+
}
916+
908917
#[test]
909918
fn fail_on_invalid_encoded_value() {
910919
let value = <$upper_type>::from($max) * 2;

0 commit comments

Comments
 (0)