From 3022ba6cab4badaa42e0dd7e4b9264987ad123ac Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Wed, 6 Apr 2022 18:25:39 -0500 Subject: [PATCH 1/2] Add test for GetMinimumDelegation stake instruction --- programs/stake/src/stake_instruction.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/programs/stake/src/stake_instruction.rs b/programs/stake/src/stake_instruction.rs index d9499eab1def38..9c2cb9644fd4eb 100644 --- a/programs/stake/src/stake_instruction.rs +++ b/programs/stake/src/stake_instruction.rs @@ -5866,4 +5866,24 @@ 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, + }]; + + process_instruction( + &instruction_data, + transaction_accounts, + instruction_accounts, + Ok(()), + ); + } } From d6af4bbc9c6a608258c23df82f7898c19c3434e8 Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Thu, 7 Apr 2022 08:59:48 -0500 Subject: [PATCH 2/2] pr: update test impl --- programs/stake/src/stake_instruction.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/programs/stake/src/stake_instruction.rs b/programs/stake/src/stake_instruction.rs index 9c2cb9644fd4eb..6edf5fbd23afe8 100644 --- a/programs/stake/src/stake_instruction.rs +++ b/programs/stake/src/stake_instruction.rs @@ -5879,11 +5879,23 @@ mod tests { is_writable: false, }]; - process_instruction( + 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(()) + }, ); } }