Skip to content

Commit

Permalink
Add test for GetMinimumDelegation stake instruction (#24158)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Apr 7, 2022
1 parent 48d1af0 commit a100b32
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions programs/stake/src/stake_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5880,4 +5880,36 @@ mod tests {
// Both fully deactivated works
try_merge(transaction_accounts, instruction_accounts, Ok(()));
}

#[test]
fn test_stake_get_minimum_delegation() {
let stake_address = Pubkey::new_unique();
let stake_account = create_default_stake_account();
let instruction_data = serialize(&StakeInstruction::GetMinimumDelegation).unwrap();
let transaction_accounts = vec![(stake_address, stake_account)];
let instruction_accounts = vec![AccountMeta {
pubkey: stake_address,
is_signer: false,
is_writable: false,
}];

mock_process_instruction(
&id(),
Vec::new(),
&instruction_data,
transaction_accounts,
instruction_accounts,
None,
Ok(()),
|first_instruction_account, invoke_context| {
super::process_instruction(first_instruction_account, invoke_context)?;
let expected_minimum_delegation =
crate::get_minimum_delegation(&invoke_context.feature_set).to_le_bytes();
let actual_minimum_delegation =
invoke_context.transaction_context.get_return_data().1;
assert_eq!(expected_minimum_delegation, actual_minimum_delegation);
Ok(())
},
);
}
}

0 comments on commit a100b32

Please sign in to comment.