Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
add tests from RentDebits
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson committed May 26, 2021
1 parent 8f7f703 commit ceb6f42
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12858,4 +12858,25 @@ pub(crate) mod tests {
0
);
}

#[test]
fn test_rent_debits() {
let mut rent_debits = RentDebits::default();

// No entry for 0 rewards
rent_debits.push(&Pubkey::default(), 0, 0);
assert_eq!(rent_debits.0.len(), 0);

// Doesn't fit an `i64`, no entry. (we'll die elsewhere)
rent_debits.push(&Pubkey::default(), u64::MAX, 0);
assert_eq!(rent_debits.0.len(), 0);

// Since we're casting from `u64` the `i64::checked_neg()` is infallible

// Some that actually work
rent_debits.push(&Pubkey::default(), 1, 0);
assert_eq!(rent_debits.0.len(), 1);
rent_debits.push(&Pubkey::default(), i64::MAX as u64, 0);
assert_eq!(rent_debits.0.len(), 2);
}
}

0 comments on commit ceb6f42

Please sign in to comment.