diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index 326cce9bee..a416f74545 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -1199,6 +1199,7 @@ pub fn mock_process_instruction( transaction_accounts: Vec, instruction_accounts: Vec, sysvar_cache_override: Option<&SysvarCache>, + feature_set_override: Option>, expected_result: Result<(), InstructionError>, process_instruction: ProcessInstructionWithContext, ) -> Vec { @@ -1218,6 +1219,9 @@ pub fn mock_process_instruction( if let Some(sysvar_cache) = sysvar_cache_override { invoke_context.sysvar_cache = Cow::Borrowed(sysvar_cache); } + if let Some(feature_set) = feature_set_override { + invoke_context.feature_set = feature_set; + } let result = invoke_context .push( &preparation.instruction_accounts, diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index f0d453f38a..ebe62b7265 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -1326,6 +1326,7 @@ mod tests { transaction_accounts, instruction_accounts, None, + None, expected_result, super::process_instruction, ) @@ -1587,6 +1588,7 @@ mod tests { vec![(program_id, program_account.clone())], Vec::new(), None, + None, Err(InstructionError::ProgramFailedToComplete), |first_instruction_account: usize, invoke_context: &mut InvokeContext| { invoke_context @@ -2852,6 +2854,7 @@ mod tests { transaction_accounts, instruction_accounts, None, + None, expected_result, super::process_instruction, ) diff --git a/programs/config/src/config_processor.rs b/programs/config/src/config_processor.rs index 8ea194a69d..39b0833cfb 100644 --- a/programs/config/src/config_processor.rs +++ b/programs/config/src/config_processor.rs @@ -169,6 +169,7 @@ mod tests { transaction_accounts, instruction_accounts, None, + None, expected_result, super::process_instruction, ) diff --git a/programs/stake/src/stake_instruction.rs b/programs/stake/src/stake_instruction.rs index 3b49174a9f..0b21dc5ff5 100644 --- a/programs/stake/src/stake_instruction.rs +++ b/programs/stake/src/stake_instruction.rs @@ -538,6 +538,7 @@ mod tests { transaction_accounts, instruction_accounts, sysvar_cache_override, + None, expected_result, super::process_instruction, ) @@ -6077,6 +6078,7 @@ mod tests { transaction_accounts, instruction_accounts, None, + None, Ok(()), |first_instruction_account, invoke_context| { super::process_instruction(first_instruction_account, invoke_context)?; @@ -6199,6 +6201,13 @@ mod tests { Err(InstructionError::NotEnoughAccountKeys), ), ] { + let mut feature_set = FeatureSet::all_enabled(); + if !is_feature_enabled { + feature_set.deactivate( + &feature_set::add_get_minimum_delegation_instruction_to_stake_program::id(), + ); + } + mock_process_instruction( &id(), Vec::new(), @@ -6206,19 +6215,9 @@ mod tests { transaction_accounts.clone(), instruction_accounts.clone(), None, + Some(Arc::new(feature_set)), expected_result, - if is_feature_enabled { - |first_instruction_account, invoke_context| { - super::process_instruction(first_instruction_account, invoke_context) - } - } else { - |first_instruction_account, invoke_context| { - let mut feature_set = FeatureSet::all_enabled(); - feature_set.deactivate(&feature_set::add_get_minimum_delegation_instruction_to_stake_program::id()); - invoke_context.feature_set = Arc::new(feature_set); - super::process_instruction(first_instruction_account, invoke_context) - } - }, + super::process_instruction, ); } } diff --git a/programs/vote/src/vote_processor.rs b/programs/vote/src/vote_processor.rs index 1e946346e5..fa87bb10f5 100644 --- a/programs/vote/src/vote_processor.rs +++ b/programs/vote/src/vote_processor.rs @@ -203,6 +203,7 @@ mod tests { transaction_accounts, instruction_accounts, None, + None, expected_result, super::process_instruction, ) @@ -221,11 +222,9 @@ mod tests { transaction_accounts, instruction_accounts, None, + Some(std::sync::Arc::new(FeatureSet::default())), expected_result, - |first_instruction_account: usize, invoke_context: &mut InvokeContext| { - invoke_context.feature_set = std::sync::Arc::new(FeatureSet::default()); - super::process_instruction(first_instruction_account, invoke_context) - }, + super::process_instruction, ) } diff --git a/runtime/src/system_instruction_processor.rs b/runtime/src/system_instruction_processor.rs index ac610dac02..4cfc33d50c 100644 --- a/runtime/src/system_instruction_processor.rs +++ b/runtime/src/system_instruction_processor.rs @@ -531,6 +531,7 @@ mod tests { transaction_accounts, instruction_accounts, None, + None, expected_result, process_instruction, )