Skip to content

Commit

Permalink
WIP: Hacks LoadedProgram::replenish() to overwrite environment of Loa…
Browse files Browse the repository at this point in the history
…dedProgramType::TestLoaded.
  • Loading branch information
Lichtso committed Oct 2, 2023
1 parent be182ac commit 2cd41cf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,18 @@ impl LoadedPrograms {
pub fn replenish(
&mut self,
key: Pubkey,
entry: Arc<LoadedProgram>,
#[allow(unused_mut)]
mut entry: Arc<LoadedProgram>,
) -> (bool, Arc<LoadedProgram>) {
#[cfg(test)]
if let LoadedProgramType::TestLoaded(_environment) = &entry.program {
entry = Arc::new(LoadedProgram {
program: LoadedProgramType::TestLoaded(
self.environments.program_runtime_v1.clone(),
),
..Arc::into_inner(entry).unwrap()
});
}
let second_level = self.entries.entry(key).or_default();
let index = second_level
.iter()
Expand Down Expand Up @@ -1269,8 +1279,9 @@ mod tests {
);

let loaded_program = new_test_loaded_program(10, 10);
let (existing, program) = cache.replenish(program1, loaded_program.clone());
let (existing, program) = cache.replenish(program1, loaded_program);
assert!(!existing);
let loaded_program = new_test_loaded_program(10, 10);
assert_eq!(program, loaded_program);
}

Expand Down

0 comments on commit 2cd41cf

Please sign in to comment.