Make test_bank_cloned_stake_delegations() aware of stake minimum delegation (#24753)
This commit is contained in:
parent
c2a44cfcee
commit
7b6880f652
|
@ -11359,16 +11359,33 @@ pub(crate) mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bank_cloned_stake_delegations() {
|
fn test_bank_cloned_stake_delegations() {
|
||||||
let GenesisConfigInfo {
|
let GenesisConfigInfo {
|
||||||
genesis_config,
|
mut genesis_config,
|
||||||
mint_keypair,
|
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 bank = Arc::new(Bank::new_for_tests(&genesis_config));
|
||||||
|
|
||||||
let stake_delegations = bank.stakes_cache.stakes().stake_delegations().clone();
|
let stake_delegations = bank.stakes_cache.stakes().stake_delegations().clone();
|
||||||
assert_eq!(stake_delegations.len(), 1); // bootstrap validator has
|
assert_eq!(stake_delegations.len(), 1); // bootstrap validator has
|
||||||
// to have a stake delegation
|
// 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 vote_keypair = Keypair::new();
|
||||||
let mut instructions = vote_instruction::create_account(
|
let mut instructions = vote_instruction::create_account(
|
||||||
&mint_keypair.pubkey(),
|
&mint_keypair.pubkey(),
|
||||||
|
@ -11379,7 +11396,7 @@ pub(crate) mod tests {
|
||||||
authorized_withdrawer: vote_keypair.pubkey(),
|
authorized_withdrawer: vote_keypair.pubkey(),
|
||||||
commission: 0,
|
commission: 0,
|
||||||
},
|
},
|
||||||
10,
|
vote_balance,
|
||||||
);
|
);
|
||||||
|
|
||||||
let stake_keypair = Keypair::new();
|
let stake_keypair = Keypair::new();
|
||||||
|
@ -11389,7 +11406,7 @@ pub(crate) mod tests {
|
||||||
&vote_keypair.pubkey(),
|
&vote_keypair.pubkey(),
|
||||||
&Authorized::auto(&stake_keypair.pubkey()),
|
&Authorized::auto(&stake_keypair.pubkey()),
|
||||||
&Lockup::default(),
|
&Lockup::default(),
|
||||||
10,
|
stake_balance,
|
||||||
));
|
));
|
||||||
|
|
||||||
let message = Message::new(&instructions, Some(&mint_keypair.pubkey()));
|
let message = Message::new(&instructions, Some(&mint_keypair.pubkey()));
|
||||||
|
|
Loading…
Reference in New Issue