Skip to content

Commit

Permalink
Turns test_load_program_effective_slot() into test_load_program_envir…
Browse files Browse the repository at this point in the history
…onment().
  • Loading branch information
Lichtso committed May 6, 2024
1 parent d58bc4e commit 1ffc298
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions svm/src/program_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,18 +827,20 @@ mod tests {
}

#[test]
fn test_load_program_effective_slot() {
fn test_load_program_environment() {
let key = Pubkey::new_unique();
let mock_bank = MockBankCallback::default();
let mut account_data = AccountSharedData::default();
account_data.set_owner(loader_v4::id());
account_data.set_owner(bpf_loader::id());
let batch_processor = TransactionBatchProcessor::<TestForkGraph>::default();

let mut upcoming_environments = ProgramRuntimeEnvironments::default();
upcoming_environments.program_runtime_v1 = Arc::new(BuiltinProgram::new_mock());
batch_processor
.program_cache
.write()
.unwrap()
.upcoming_environments = Some(ProgramRuntimeEnvironments::default());
.upcoming_environments = Some(upcoming_environments.clone());
mock_bank
.account_shared_data
.borrow_mut()
Expand All @@ -851,12 +853,15 @@ mod tests {
&program_cache,
&key,
200,
20,
1,
&batch_processor.epoch_schedule,
false,
);
)
.unwrap();

let slot = batch_processor.epoch_schedule.get_first_slot_in_epoch(20);
assert_eq!(result.unwrap().effective_slot, slot);
assert!(Arc::ptr_eq(
result.program.get_environment().unwrap(),
&upcoming_environments.program_runtime_v1
));
}
}

0 comments on commit 1ffc298

Please sign in to comment.