Minor test cleanup and comments (backport #17283) (#17295)

* Minor test cleanup and comments (#17283)

(cherry picked from commit bcbe155575)

# Conflicts:
#	runtime/src/rent_collector.rs

* Fix conflicts

* More clean cherry-pick...

Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
This commit is contained in:
mergify[bot]
2021-05-18 03:50:28 +00:00
committed by GitHub
parent 00d1cb0333
commit e182afa50f
2 changed files with 9 additions and 4 deletions

View File

@ -5872,7 +5872,7 @@ pub(crate) mod tests {
let sysvar_and_native_proram_delta = 1;
assert_eq!(
previous_capitalization - current_capitalization + sysvar_and_native_proram_delta,
previous_capitalization - (current_capitalization - sysvar_and_native_proram_delta),
burned_portion
);
@ -8340,6 +8340,7 @@ pub(crate) mod tests {
use sysvar::clock::Clock;
let dummy_clock_id = solana_sdk::pubkey::new_rand();
let dummy_rent_epoch = 44;
let (mut genesis_config, _mint_keypair) = create_genesis_config(500);
let expected_previous_slot = 3;
@ -8356,19 +8357,22 @@ pub(crate) mod tests {
bank1.update_sysvar_account(&dummy_clock_id, |optional_account| {
assert!(optional_account.is_none());
create_account(
let mut account = create_account(
&Clock {
slot: expected_previous_slot,
..Clock::default()
},
bank1.inherit_specially_retained_account_fields(optional_account),
)
);
account.rent_epoch = dummy_rent_epoch;
account
});
let current_account = bank1.get_account(&dummy_clock_id).unwrap();
assert_eq!(
expected_previous_slot,
from_account::<Clock, _>(&current_account).unwrap().slot
);
assert_eq!(dummy_rent_epoch, current_account.rent_epoch);
},
|old, new| {
assert_eq!(old + 1, new);
@ -8420,6 +8424,7 @@ pub(crate) mod tests {
expected_next_slot,
from_account::<Clock, _>(&current_account).unwrap().slot
);
assert_eq!(INITIAL_RENT_EPOCH, current_account.rent_epoch);
},
|old, new| {
// if existing, capitalization shouldn't change

View File

@ -61,7 +61,7 @@ impl RentCollector {
address: &Pubkey,
account: &mut AccountSharedData,
) -> u64 {
if account.executable
if account.executable // executable accounts must be rent-exempt balance
|| account.rent_epoch > self.epoch
|| sysvar::check_id(&account.owner)
|| *address == incinerator::id()