Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for GetMinimumDelegation stake instruction #24158

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions programs/stake/src/stake_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5866,4 +5866,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(())
},
);
}
}