Add feature_set_override parameter to mock_process_instruction() (#24386)
This commit is contained in:
parent
34418cb848
commit
f33ad34531
@ -1199,6 +1199,7 @@ pub fn mock_process_instruction(
|
||||
transaction_accounts: Vec<TransactionAccount>,
|
||||
instruction_accounts: Vec<AccountMeta>,
|
||||
sysvar_cache_override: Option<&SysvarCache>,
|
||||
feature_set_override: Option<Arc<FeatureSet>>,
|
||||
expected_result: Result<(), InstructionError>,
|
||||
process_instruction: ProcessInstructionWithContext,
|
||||
) -> Vec<AccountSharedData> {
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
)
|
||||
|
@ -169,6 +169,7 @@ mod tests {
|
||||
transaction_accounts,
|
||||
instruction_accounts,
|
||||
None,
|
||||
None,
|
||||
expected_result,
|
||||
super::process_instruction,
|
||||
)
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -531,6 +531,7 @@ mod tests {
|
||||
transaction_accounts,
|
||||
instruction_accounts,
|
||||
None,
|
||||
None,
|
||||
expected_result,
|
||||
process_instruction,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user