mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +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
@@ -425,7 +425,7 @@ macro_rules! implement_per_thing {
|
||||
///
|
||||
#[doc = $title]
|
||||
#[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);
|
||||
|
||||
/// 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]
|
||||
fn fail_on_invalid_encoded_value() {
|
||||
let value = <$upper_type>::from($max) * 2;
|
||||
|
||||
Reference in New Issue
Block a user