Add feature_set_override parameter to mock_process_instruction() (#24386)

This commit is contained in:
Brooks Prumo
2022-04-15 13:43:04 -05:00
committed by GitHub
parent 34418cb848
commit f33ad34531
6 changed files with 23 additions and 16 deletions

View File

@@ -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,
);
}
}