Skip to content

Commit

Permalink
Fix deprecated decrease tests by transferring rent-exempt reserve
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque committed Sep 20, 2023
1 parent 236f4b4 commit 26953b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
6 changes: 1 addition & 5 deletions stake-pool/program/tests/decrease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ async fn success(instruction_type: DecreaseInstruction) {
.await;
let transient_stake_state =
deserialize::<stake::state::StakeState>(&transient_stake_account.data).unwrap();
let transient_lamports = if instruction_type == DecreaseInstruction::Deprecated {
decrease_lamports
} else {
decrease_lamports + stake_rent
};
let transient_lamports = decrease_lamports + stake_rent;
assert_eq!(transient_stake_account.lamports, transient_lamports);
let reserve_lamports = if instruction_type == DecreaseInstruction::Deprecated {
reserve_lamports
Expand Down
29 changes: 18 additions & 11 deletions stake-pool/program/tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,17 +1625,24 @@ impl StakePoolAccounts {
transient_stake_seed: u64,
) -> Option<TransportError> {
#[allow(deprecated)]
let mut instructions = vec![instruction::decrease_validator_stake(
&id(),
&self.stake_pool.pubkey(),
&self.staker.pubkey(),
&self.withdraw_authority,
&self.validator_list.pubkey(),
validator_stake,
transient_stake,
lamports,
transient_stake_seed,
)];
let mut instructions = vec![
system_instruction::transfer(
&payer.pubkey(),
transient_stake,
STAKE_ACCOUNT_RENT_EXEMPTION,
),
instruction::decrease_validator_stake(
&id(),
&self.stake_pool.pubkey(),
&self.staker.pubkey(),
&self.withdraw_authority,
&self.validator_list.pubkey(),
validator_stake,
transient_stake,
lamports,
transient_stake_seed,
),
];
self.maybe_add_compute_budget_instruction(&mut instructions);
let transaction = Transaction::new_signed_with_payer(
&instructions,
Expand Down

0 comments on commit 26953b5

Please sign in to comment.