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>,
|
transaction_accounts: Vec<TransactionAccount>,
|
||||||
instruction_accounts: Vec<AccountMeta>,
|
instruction_accounts: Vec<AccountMeta>,
|
||||||
sysvar_cache_override: Option<&SysvarCache>,
|
sysvar_cache_override: Option<&SysvarCache>,
|
||||||
|
feature_set_override: Option<Arc<FeatureSet>>,
|
||||||
expected_result: Result<(), InstructionError>,
|
expected_result: Result<(), InstructionError>,
|
||||||
process_instruction: ProcessInstructionWithContext,
|
process_instruction: ProcessInstructionWithContext,
|
||||||
) -> Vec<AccountSharedData> {
|
) -> Vec<AccountSharedData> {
|
||||||
@ -1218,6 +1219,9 @@ pub fn mock_process_instruction(
|
|||||||
if let Some(sysvar_cache) = sysvar_cache_override {
|
if let Some(sysvar_cache) = sysvar_cache_override {
|
||||||
invoke_context.sysvar_cache = Cow::Borrowed(sysvar_cache);
|
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
|
let result = invoke_context
|
||||||
.push(
|
.push(
|
||||||
&preparation.instruction_accounts,
|
&preparation.instruction_accounts,
|
||||||
|
@ -1326,6 +1326,7 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
expected_result,
|
expected_result,
|
||||||
super::process_instruction,
|
super::process_instruction,
|
||||||
)
|
)
|
||||||
@ -1587,6 +1588,7 @@ mod tests {
|
|||||||
vec![(program_id, program_account.clone())],
|
vec![(program_id, program_account.clone())],
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Err(InstructionError::ProgramFailedToComplete),
|
Err(InstructionError::ProgramFailedToComplete),
|
||||||
|first_instruction_account: usize, invoke_context: &mut InvokeContext| {
|
|first_instruction_account: usize, invoke_context: &mut InvokeContext| {
|
||||||
invoke_context
|
invoke_context
|
||||||
@ -2852,6 +2854,7 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
expected_result,
|
expected_result,
|
||||||
super::process_instruction,
|
super::process_instruction,
|
||||||
)
|
)
|
||||||
|
@ -169,6 +169,7 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
expected_result,
|
expected_result,
|
||||||
super::process_instruction,
|
super::process_instruction,
|
||||||
)
|
)
|
||||||
|
@ -538,6 +538,7 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
sysvar_cache_override,
|
sysvar_cache_override,
|
||||||
|
None,
|
||||||
expected_result,
|
expected_result,
|
||||||
super::process_instruction,
|
super::process_instruction,
|
||||||
)
|
)
|
||||||
@ -6077,6 +6078,7 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Ok(()),
|
Ok(()),
|
||||||
|first_instruction_account, invoke_context| {
|
|first_instruction_account, invoke_context| {
|
||||||
super::process_instruction(first_instruction_account, invoke_context)?;
|
super::process_instruction(first_instruction_account, invoke_context)?;
|
||||||
@ -6199,6 +6201,13 @@ mod tests {
|
|||||||
Err(InstructionError::NotEnoughAccountKeys),
|
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(
|
mock_process_instruction(
|
||||||
&id(),
|
&id(),
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
@ -6206,19 +6215,9 @@ mod tests {
|
|||||||
transaction_accounts.clone(),
|
transaction_accounts.clone(),
|
||||||
instruction_accounts.clone(),
|
instruction_accounts.clone(),
|
||||||
None,
|
None,
|
||||||
|
Some(Arc::new(feature_set)),
|
||||||
expected_result,
|
expected_result,
|
||||||
if is_feature_enabled {
|
super::process_instruction,
|
||||||
|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)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,7 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
expected_result,
|
expected_result,
|
||||||
super::process_instruction,
|
super::process_instruction,
|
||||||
)
|
)
|
||||||
@ -221,11 +222,9 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
None,
|
None,
|
||||||
|
Some(std::sync::Arc::new(FeatureSet::default())),
|
||||||
expected_result,
|
expected_result,
|
||||||
|first_instruction_account: usize, invoke_context: &mut InvokeContext| {
|
super::process_instruction,
|
||||||
invoke_context.feature_set = std::sync::Arc::new(FeatureSet::default());
|
|
||||||
super::process_instruction(first_instruction_account, invoke_context)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,6 +531,7 @@ mod tests {
|
|||||||
transaction_accounts,
|
transaction_accounts,
|
||||||
instruction_accounts,
|
instruction_accounts,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
expected_result,
|
expected_result,
|
||||||
process_instruction,
|
process_instruction,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user