mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 17:28:00 +00:00
Fuzz testing for nomination pools (#12002)
* some additional tests and stuff * make sanity public * add some sort of fuzz test for pools * breaks every now and then * breaks every now and then * IT WORKS AND PASSES 100k TESTS * cleanup * safe id addition * fix assert_eq_error_rate * Update frame/nomination-pools/src/tests.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update frame/nomination-pools/src/tests.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * add some doc * Fix * ".git/.scripts/fmt.sh" 1 Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <>
This commit is contained in:
@@ -36,6 +36,8 @@ pub use sp_std;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use paste;
|
||||
#[doc(hidden)]
|
||||
pub use sp_arithmetic::traits::Saturating;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use sp_application_crypto as app_crypto;
|
||||
@@ -825,7 +827,24 @@ pub fn verify_encoded_lazy<V: Verify, T: codec::Encode>(
|
||||
macro_rules! assert_eq_error_rate {
|
||||
($x:expr, $y:expr, $error:expr $(,)?) => {
|
||||
assert!(
|
||||
($x) >= (($y) - ($error)) && ($x) <= (($y) + ($error)),
|
||||
($x >= $crate::Saturating::saturating_sub($y, $error)) &&
|
||||
($x <= $crate::Saturating::saturating_add($y, $error)),
|
||||
"{:?} != {:?} (with error rate {:?})",
|
||||
$x,
|
||||
$y,
|
||||
$error,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
/// Same as [`assert_eq_error_rate`], but intended to be used with floating point number, or
|
||||
/// generally those who do not have over/underflow potentials.
|
||||
#[macro_export]
|
||||
#[cfg(feature = "std")]
|
||||
macro_rules! assert_eq_error_rate_float {
|
||||
($x:expr, $y:expr, $error:expr $(,)?) => {
|
||||
assert!(
|
||||
($x >= $y - $error) && ($x <= $y + $error),
|
||||
"{:?} != {:?} (with error rate {:?})",
|
||||
$x,
|
||||
$y,
|
||||
|
||||
Reference in New Issue
Block a user