Skip to content

Commit

Permalink
add failing test for itamar
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma committed Jul 31, 2022
1 parent 7d8e5a1 commit bdd1399
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bdd1399

Please sign in to comment.