From bdd139989cb4dfa8cc6cc6b5ee470a711df32d25 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Sun, 31 Jul 2022 13:27:13 +0100 Subject: [PATCH] add failing test for itamar --- frame/staking/src/tests.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index d14d8c4a75f2e..646645fdf56a0 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5102,6 +5102,21 @@ fn proportional_ledger_slash_works() { assert_eq!(LedgerSlashPerEra::get().0, 0); assert_eq!(LedgerSlashPerEra::get().1, BTreeMap::from([(6, 30), (7, 30)])); + // Given + ledger.unlocking = bounded_vec![c(4, 100), c(5, 100), c(6, 100), c(7, 100)]; + ledger.total = 4 * 100; + ledger.active = 0; + // When the first 2 chunks don't overlap with the affected range of unlock eras. + assert_eq!(ledger.slash(15, 0, 3), 15); + // Then + assert_eq!(ledger.unlocking, vec![c(4, 100), c(5, 99), c(6, 100 - 7), c(7, 100 - 7)]); + // ISSUE: The sum of everything we round down is affecting chunk 5, which should have ideally + // remained unchanged. + assert_eq!(ledger.total, 4 * 100 - 15); + assert_eq!(LedgerSlashPerEra::get().0, 0); + assert_eq!(LedgerSlashPerEra::get().1, BTreeMap::from([(5, 99), (6, 93), (7, 93)])); + panic!(); + // Given ledger.unlocking = bounded_vec![c(4, 40), c(5, 100), c(6, 10), c(7, 250)]; ledger.active = 500;