Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 committed Aug 14, 2023
1 parent a81b695 commit d3aa175
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion programs/loader-v4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,49 @@ mod tests {
std::{fs::File, io::Read, path::Path},
};

pub fn load_all_invoked_programs(invoke_context: &mut InvokeContext) {
let mut load_program_metrics = LoadProgramMetrics::default();
let num_accounts = invoke_context.transaction_context.get_number_of_accounts();
for index in 0..num_accounts {
let account = invoke_context
.transaction_context
.get_account_at_index(index)
.expect("Failed to get the account")
.borrow();

let owner = account.owner();
if loader_v4::check_id(owner) {
let pubkey = invoke_context
.transaction_context
.get_key_of_account_at_index(index)
.expect("Failed to get account key");

if let Some(programdata) =
account.data().get(LoaderV4State::program_data_offset()..)
{
if let Ok(loaded_program) = LoadedProgram::new(
&loader_v4::id(),
invoke_context
.programs_modified_by_tx
.program_runtime_environment_v2
.clone(),
0,
0,
None,
programdata,
account.data().len(),
&mut load_program_metrics,
) {
invoke_context.programs_modified_by_tx.set_slot_for_tests(0);
invoke_context
.programs_modified_by_tx
.replenish(*pubkey, Arc::new(loaded_program));
}
}
}
}
}

fn process_instruction(
program_indices: Vec<IndexOfAccount>,
instruction_data: &[u8],
Expand All @@ -689,7 +732,14 @@ mod tests {
instruction_accounts,
expected_result,
super::process_instruction,
|_invoke_context| {},
|invoke_context| {
invoke_context
.programs_modified_by_tx
.program_runtime_environment_v2 = Arc::new(
create_program_runtime_environment_v2(&ComputeBudget::default(), false),
);
load_all_invoked_programs(invoke_context);
},
|_invoke_context| {},
)
}
Expand Down

0 comments on commit d3aa175

Please sign in to comment.