Simplify account.rent_epoch handling for sysvar rent (#16049)

* Add some code for special local testing

* Add comment to store_account_and_update_capitalization

* Simplify account.rent_epoch handling for sysvar rent

* Introduce *_for_test functions

* Add deprecation messages to existing api
This commit is contained in:
Ryo Onodera
2021-03-25 15:23:20 +09:00
committed by GitHub
parent 7f0ac6a67c
commit 6d5c6c17c5
16 changed files with 206 additions and 104 deletions

View File

@ -1,14 +1,32 @@
use crate::account::{Account, AccountSharedData};
use crate::account::{
Account, AccountSharedData, InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS,
};
use crate::clock::INITIAL_RENT_EPOCH;
crate::declare_id!("NativeLoader1111111111111111111111111111111");
/// Create an executable account with the given shared object name.
#[deprecated(
since = "1.5.17",
note = "Please use `create_loadable_account_for_test` instead"
)]
pub fn create_loadable_account(name: &str, lamports: u64) -> AccountSharedData {
create_loadable_account_with_fields(name, (lamports, INITIAL_RENT_EPOCH))
}
pub fn create_loadable_account_with_fields(
name: &str,
(lamports, rent_epoch): InheritableAccountFields,
) -> AccountSharedData {
AccountSharedData::from(Account {
lamports,
owner: id(),
data: name.as_bytes().to_vec(),
executable: true,
rent_epoch: 0,
rent_epoch,
})
}
pub fn create_loadable_account_for_test(name: &str) -> AccountSharedData {
create_loadable_account_with_fields(name, DUMMY_INHERITABLE_ACCOUNT_FIELDS)
}