From 1a84ad87c0bd4d61c7760cb4d7ef11f047d3b69d Mon Sep 17 00:00:00 2001
From: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Date: Mon, 3 Aug 2020 15:26:09 +0200
Subject: [PATCH] Add integrity test for slash defer duration (#6782)

* Add integrity test for slash defer duration

* Wrap in externalities

* Update frame/staking/src/lib.rs
---
 substrate/frame/staking/src/lib.rs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs
index cd820051b15..60943be82f1 100644
--- a/substrate/frame/staking/src/lib.rs
+++ b/substrate/frame/staking/src/lib.rs
@@ -1459,6 +1459,17 @@ decl_module! {
 			// `on_finalize` weight is tracked in `on_initialize`
 		}
 
+		fn integrity_test() {
+			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(),
+				)
+			);
+		}
+
 		/// Take the origin account as a stash and lock up `value` of its balance. `controller` will
 		/// be the account that controls it.
 		///
-- 
GitLab