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

@@ -663,15 +663,17 @@ mod tests {
.iter()
.map(|meta| {
RefCell::new(if sysvar::clock::check_id(&meta.pubkey) {
account::create_account_shared_data(&sysvar::clock::Clock::default(), 1)
account::create_account_shared_data_for_test(&sysvar::clock::Clock::default())
} else if sysvar::rewards::check_id(&meta.pubkey) {
account::create_account_shared_data(&sysvar::rewards::Rewards::new(0.0), 1)
account::create_account_shared_data_for_test(&sysvar::rewards::Rewards::new(
0.0,
))
} else if sysvar::stake_history::check_id(&meta.pubkey) {
account::create_account_shared_data(&StakeHistory::default(), 1)
account::create_account_shared_data_for_test(&StakeHistory::default())
} else if config::check_id(&meta.pubkey) {
config::create_account(0, &config::Config::default())
} else if sysvar::rent::check_id(&meta.pubkey) {
account::create_account_shared_data(&Rent::default(), 1)
account::create_account_shared_data_for_test(&Rent::default())
} else if meta.pubkey == invalid_stake_state_pubkey() {
AccountSharedData::from(Account {
owner: id(),
@@ -973,7 +975,9 @@ mod tests {
KeyedAccount::new(
&sysvar::rent::id(),
false,
&RefCell::new(account::create_account_shared_data(&Rent::default(), 0))
&RefCell::new(account::create_account_shared_data_for_test(
&Rent::default()
))
)
],
&serialize(&StakeInstruction::Initialize(
@@ -1028,17 +1032,15 @@ mod tests {
KeyedAccount::new(
&sysvar::clock::id(),
false,
&RefCell::new(account::create_account_shared_data(
&RefCell::new(account::create_account_shared_data_for_test(
&sysvar::clock::Clock::default(),
1
))
),
KeyedAccount::new(
&sysvar::stake_history::id(),
false,
&RefCell::new(account::create_account_shared_data(
&RefCell::new(account::create_account_shared_data_for_test(
&sysvar::stake_history::StakeHistory::default(),
1
))
),
KeyedAccount::new(
@@ -1063,17 +1065,15 @@ mod tests {
KeyedAccount::new(
&sysvar::rewards::id(),
false,
&RefCell::new(account::create_account_shared_data(
&RefCell::new(account::create_account_shared_data_for_test(
&sysvar::rewards::Rewards::new(0.0),
1
))
),
KeyedAccount::new(
&sysvar::stake_history::id(),
false,
&RefCell::new(account::create_account_shared_data(
&RefCell::new(account::create_account_shared_data_for_test(
&StakeHistory::default(),
1,
))
),
],
@@ -1107,9 +1107,8 @@ mod tests {
KeyedAccount::new(
&sysvar::rewards::id(),
false,
&RefCell::new(account::create_account_shared_data(
&RefCell::new(account::create_account_shared_data_for_test(
&sysvar::rewards::Rewards::new(0.0),
1
))
),
],