From e182afa50fe0fd7b6cddfa0db3c308174fb1dff7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 18 May 2021 03:50:28 +0000 Subject: [PATCH] Minor test cleanup and comments (backport #17283) (#17295) * Minor test cleanup and comments (#17283) (cherry picked from commit bcbe1555756e15f13de956d9549f5d94153d8b84) # Conflicts: # runtime/src/rent_collector.rs * Fix conflicts * More clean cherry-pick... Co-authored-by: Ryo Onodera --- runtime/src/bank.rs | 11 ++++++++--- runtime/src/rent_collector.rs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 681ff568fe..b17ecc8a1c 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -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::(¤t_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::(¤t_account).unwrap().slot ); + assert_eq!(INITIAL_RENT_EPOCH, current_account.rent_epoch); }, |old, new| { // if existing, capitalization shouldn't change diff --git a/runtime/src/rent_collector.rs b/runtime/src/rent_collector.rs index 5434659c26..f14dfefc2f 100644 --- a/runtime/src/rent_collector.rs +++ b/runtime/src/rent_collector.rs @@ -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()