Skip to content

Commit

Permalink
Make test_bank_cloned_stake_delegations() aware of stake minimum dele…
Browse files Browse the repository at this point in the history
…gation (solana-labs#24753)
  • Loading branch information
brooksprumo authored and jeffwashington committed Jun 29, 2022
1 parent 7f8214c commit 6051670
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11438,16 +11438,33 @@ pub(crate) mod tests {
#[test]
fn test_bank_cloned_stake_delegations() {
let GenesisConfigInfo {
genesis_config,
mut genesis_config,
mint_keypair,
..
} = create_genesis_config_with_leader(500, &solana_sdk::pubkey::new_rand(), 1);
} = create_genesis_config_with_leader(
123_456_000_000_000,
&solana_sdk::pubkey::new_rand(),
123_000_000_000,
);
genesis_config.rent = Rent::default();
let bank = Arc::new(Bank::new_for_tests(&genesis_config));

let stake_delegations = bank.stakes_cache.stakes().stake_delegations().clone();
assert_eq!(stake_delegations.len(), 1); // bootstrap validator has
// to have a stake delegation

let (vote_balance, stake_balance) = {
let rent = &bank.rent_collector().rent;
let vote_rent_exempt_reserve = rent.minimum_balance(VoteState::size_of());
let stake_rent_exempt_reserve = rent.minimum_balance(StakeState::size_of());
let minimum_delegation =
solana_stake_program::get_minimum_delegation(&bank.feature_set);
(
vote_rent_exempt_reserve,
stake_rent_exempt_reserve + minimum_delegation,
)
};

let vote_keypair = Keypair::new();
let mut instructions = vote_instruction::create_account(
&mint_keypair.pubkey(),
Expand All @@ -11458,7 +11475,7 @@ pub(crate) mod tests {
authorized_withdrawer: vote_keypair.pubkey(),
commission: 0,
},
10,
vote_balance,
);

let stake_keypair = Keypair::new();
Expand All @@ -11468,7 +11485,7 @@ pub(crate) mod tests {
&vote_keypair.pubkey(),
&Authorized::auto(&stake_keypair.pubkey()),
&Lockup::default(),
10,
stake_balance,
));

let message = Message::new(&instructions, Some(&mint_keypair.pubkey()));
Expand Down

0 comments on commit 6051670

Please sign in to comment.