Skip to content

Commit bdd1399

Browse files
committed
add failing test for itamar
1 parent 7d8e5a1 commit bdd1399

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

frame/staking/src/tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5102,6 +5102,21 @@ fn proportional_ledger_slash_works() {
51025102
assert_eq!(LedgerSlashPerEra::get().0, 0);
51035103
assert_eq!(LedgerSlashPerEra::get().1, BTreeMap::from([(6, 30), (7, 30)]));
51045104

5105+
// Given
5106+
ledger.unlocking = bounded_vec![c(4, 100), c(5, 100), c(6, 100), c(7, 100)];
5107+
ledger.total = 4 * 100;
5108+
ledger.active = 0;
5109+
// When the first 2 chunks don't overlap with the affected range of unlock eras.
5110+
assert_eq!(ledger.slash(15, 0, 3), 15);
5111+
// Then
5112+
assert_eq!(ledger.unlocking, vec![c(4, 100), c(5, 99), c(6, 100 - 7), c(7, 100 - 7)]);
5113+
// ISSUE: The sum of everything we round down is affecting chunk 5, which should have ideally
5114+
// remained unchanged.
5115+
assert_eq!(ledger.total, 4 * 100 - 15);
5116+
assert_eq!(LedgerSlashPerEra::get().0, 0);
5117+
assert_eq!(LedgerSlashPerEra::get().1, BTreeMap::from([(5, 99), (6, 93), (7, 93)]));
5118+
panic!();
5119+
51055120
// Given
51065121
ledger.unlocking = bounded_vec![c(4, 40), c(5, 100), c(6, 10), c(7, 250)];
51075122
ledger.active = 500;

0 commit comments

Comments
 (0)