Run integrity_test in Externalities (#14546)

* Run integrity_test in RO externalities

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* frame-support: Export RO externalities

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix bench tests

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update docs

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Rename to __private

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Run in TestExternalities

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix other pallets

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update docs

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fixes

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/support/src/dispatch.rs

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* Fixup merge

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: parity-processbot <>
Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
This commit is contained in:
Oliver Tale-Yazdi
2023-07-18 12:10:56 +02:00
committed by GitHub
parent 26d8e65910
commit 5b89f47df2
7 changed files with 37 additions and 47 deletions
+15 -18
View File
@@ -416,6 +416,7 @@ pub mod pallet {
});
}
#[cfg(feature = "std")]
fn integrity_test() {
// given weight == u64, we build multipliers from `diff` of two weight values, which can
// at most be maximum block weight. Make sure that this can fit in a multiplier without
@@ -441,25 +442,21 @@ pub mod pallet {
return
}
#[cfg(any(feature = "std", test))]
sp_io::TestExternalities::new_empty().execute_with(|| {
// This is the minimum value of the multiplier. Make sure that if we collapse to
// this value, we can recover with a reasonable amount of traffic. For this test we
// assert that if we collapse to minimum, the trend will be positive with a weight
// value which is 1% more than the target.
let min_value = T::FeeMultiplierUpdate::min();
// This is the minimum value of the multiplier. Make sure that if we collapse to this
// value, we can recover with a reasonable amount of traffic. For this test we assert
// that if we collapse to minimum, the trend will be positive with a weight value which
// is 1% more than the target.
let min_value = T::FeeMultiplierUpdate::min();
let target = target + addition;
let target = target + addition;
<frame_system::Pallet<T>>::set_block_consumed_resources(target, 0);
let next = T::FeeMultiplierUpdate::convert(min_value);
assert!(
next > min_value,
"The minimum bound of the multiplier is too low. When \
block saturation is more than target by 1% and multiplier is minimal then \
the multiplier doesn't increase."
);
});
<frame_system::Pallet<T>>::set_block_consumed_resources(target, 0);
let next = T::FeeMultiplierUpdate::convert(min_value);
assert!(
next > min_value,
"The minimum bound of the multiplier is too low. When \
block saturation is more than target by 1% and multiplier is minimal then \
the multiplier doesn't increase."
);
}
}
}