* 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
(cherry picked from commit 6d5c6c17c5
)
# Conflicts:
# programs/bpf_loader/src/lib.rs
# programs/stake/src/stake_instruction.rs
# programs/vote/src/vote_instruction.rs
# runtime/src/accounts.rs
# runtime/src/bank.rs
# runtime/src/message_processor.rs
# runtime/src/system_instruction_processor.rs
# sdk/benches/slot_hashes.rs
# sdk/benches/slot_history.rs
# sdk/src/account.rs
# sdk/src/keyed_account.rs
# sdk/src/native_loader.rs
# sdk/src/recent_blockhashes_account.rs
* Fix conflicts
* rustfmt
Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
This commit is contained in:
@@ -897,7 +897,7 @@ mod tests {
|
||||
message_processor::{Executors, ThisInvokeContext},
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::{create_account, Account},
|
||||
account::{create_account_for_test, Account},
|
||||
account_utils::StateMut,
|
||||
client::SyncClient,
|
||||
clock::Clock,
|
||||
@@ -2214,15 +2214,12 @@ mod tests {
|
||||
file.read_to_end(&mut elf_new).unwrap();
|
||||
assert_ne!(elf_orig.len(), elf_new.len());
|
||||
let rent = Rent::default();
|
||||
let rent_account = RefCell::new(create_account(&Rent::default(), 1));
|
||||
let rent_account = RefCell::new(create_account_for_test(&Rent::default()));
|
||||
let slot = 42;
|
||||
let clock_account = RefCell::new(create_account(
|
||||
&Clock {
|
||||
slot,
|
||||
..Clock::default()
|
||||
},
|
||||
1,
|
||||
));
|
||||
let clock_account = RefCell::new(create_account_for_test(&Clock {
|
||||
slot,
|
||||
..Clock::default()
|
||||
}));
|
||||
let min_program_balance =
|
||||
1.max(rent.minimum_balance(UpgradeableLoaderState::program_len().unwrap()));
|
||||
let min_programdata_balance = 1.max(rent.minimum_balance(
|
||||
|
@@ -663,15 +663,15 @@ mod tests {
|
||||
.iter()
|
||||
.map(|meta| {
|
||||
RefCell::new(if sysvar::clock::check_id(&meta.pubkey) {
|
||||
account::create_account(&sysvar::clock::Clock::default(), 1)
|
||||
account::create_account_for_test(&sysvar::clock::Clock::default())
|
||||
} else if sysvar::rewards::check_id(&meta.pubkey) {
|
||||
account::create_account(&sysvar::rewards::Rewards::new(0.0), 1)
|
||||
account::create_account_for_test(&sysvar::rewards::Rewards::new(0.0))
|
||||
} else if sysvar::stake_history::check_id(&meta.pubkey) {
|
||||
account::create_account(&StakeHistory::default(), 1)
|
||||
account::create_account_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(&Rent::default(), 1)
|
||||
account::create_account_for_test(&Rent::default())
|
||||
} else if meta.pubkey == invalid_stake_state_pubkey() {
|
||||
Account {
|
||||
owner: id(),
|
||||
@@ -973,7 +973,7 @@ mod tests {
|
||||
KeyedAccount::new(
|
||||
&sysvar::rent::id(),
|
||||
false,
|
||||
&RefCell::new(account::create_account(&Rent::default(), 0))
|
||||
&RefCell::new(account::create_account_for_test(&Rent::default()))
|
||||
)
|
||||
],
|
||||
&serialize(&StakeInstruction::Initialize(
|
||||
@@ -1028,14 +1028,15 @@ mod tests {
|
||||
KeyedAccount::new(
|
||||
&sysvar::clock::id(),
|
||||
false,
|
||||
&RefCell::new(account::create_account(&sysvar::clock::Clock::default(), 1))
|
||||
&RefCell::new(account::create_account_for_test(
|
||||
&sysvar::clock::Clock::default()
|
||||
))
|
||||
),
|
||||
KeyedAccount::new(
|
||||
&sysvar::stake_history::id(),
|
||||
false,
|
||||
&RefCell::new(account::create_account(
|
||||
&RefCell::new(account::create_account_for_test(
|
||||
&sysvar::stake_history::StakeHistory::default(),
|
||||
1
|
||||
))
|
||||
),
|
||||
KeyedAccount::new(
|
||||
@@ -1060,15 +1061,14 @@ mod tests {
|
||||
KeyedAccount::new(
|
||||
&sysvar::rewards::id(),
|
||||
false,
|
||||
&RefCell::new(account::create_account(
|
||||
&RefCell::new(account::create_account_for_test(
|
||||
&sysvar::rewards::Rewards::new(0.0),
|
||||
1
|
||||
))
|
||||
),
|
||||
KeyedAccount::new(
|
||||
&sysvar::stake_history::id(),
|
||||
false,
|
||||
&RefCell::new(account::create_account(&StakeHistory::default(), 1,))
|
||||
&RefCell::new(account::create_account_for_test(&StakeHistory::default()))
|
||||
),
|
||||
],
|
||||
&serialize(&StakeInstruction::Withdraw(42)).unwrap(),
|
||||
@@ -1101,9 +1101,8 @@ mod tests {
|
||||
KeyedAccount::new(
|
||||
&sysvar::rewards::id(),
|
||||
false,
|
||||
&RefCell::new(account::create_account(
|
||||
&RefCell::new(account::create_account_for_test(
|
||||
&sysvar::rewards::Rewards::new(0.0),
|
||||
1
|
||||
))
|
||||
),
|
||||
],
|
||||
|
@@ -370,11 +370,11 @@ mod tests {
|
||||
.iter()
|
||||
.map(|meta| {
|
||||
RefCell::new(if sysvar::clock::check_id(&meta.pubkey) {
|
||||
account::create_account(&Clock::default(), 1)
|
||||
account::create_account_for_test(&Clock::default())
|
||||
} else if sysvar::slot_hashes::check_id(&meta.pubkey) {
|
||||
account::create_account(&SlotHashes::default(), 1)
|
||||
account::create_account_for_test(&SlotHashes::default())
|
||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||
account::create_account(&Rent::free(), 1)
|
||||
account::create_account_for_test(&Rent::free())
|
||||
} else if meta.pubkey == invalid_vote_state_pubkey() {
|
||||
Account {
|
||||
owner: invalid_vote_state_pubkey(),
|
||||
|
Reference in New Issue
Block a user