From a419042030d1e6096351ee35443b940467ef3892 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Fri, 31 Jul 2020 12:17:32 +0200 Subject: [PATCH 1/3] Add integrity test for slash defer duration --- frame/staking/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index cd820051b157f..c9b2952522afe 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -1459,6 +1459,13 @@ decl_module! { // `on_finalize` weight is tracked in `on_initialize` } + fn integrity_test() { + assert!( + T::SlashDeferDuration::get() < T::BondingDuration::get() || T::BondingDuration::get() == 0, + "As per documentation, slash defer duration should be less than bonding duration.", + ); + } + /// Take the origin account as a stash and lock up `value` of its balance. `controller` will /// be the account that controls it. /// From 1da4aca6e0fdeab592b00208fa47c323666a6a60 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Mon, 3 Aug 2020 14:55:48 +0200 Subject: [PATCH 2/3] Wrap in externalities --- frame/staking/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index c9b2952522afe..0aa663f16a134 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -1460,9 +1460,14 @@ decl_module! { } fn integrity_test() { - assert!( - T::SlashDeferDuration::get() < T::BondingDuration::get() || T::BondingDuration::get() == 0, - "As per documentation, slash defer duration should be less than bonding duration.", + sp_io::TestExternalities::new_empty().execute_with(|| + assert!( + T::SlashDeferDuration::get() < T::BondingDuration::get() || T::BondingDuration::get() == 0, + "As per documentation, slash defer duration ({}) should be less than bonding duration ({}).", + T::SlashDeferDuration::get(), + T::BondingDuration::get(), + + ) ); } From 47aa94c70ca3b8e415a23dfb77047c8a7170b32a Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:56:37 +0200 Subject: [PATCH 3/3] Update frame/staking/src/lib.rs --- frame/staking/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 0aa663f16a134..60943be82f1dc 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -1466,7 +1466,6 @@ decl_module! { "As per documentation, slash defer duration ({}) should be less than bonding duration ({}).", T::SlashDeferDuration::get(), T::BondingDuration::get(), - ) ); }