Skip to content

Commit

Permalink
Adds test_unloaded().
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Feb 13, 2024
1 parent 44dfcc3 commit 6491692
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,38 @@ mod tests {
assert!(match_missing(&missing, &program3, true));
}

#[test]
fn test_unloaded() {
let cache = new_mock_cache::<TestForkGraph>();
for loaded_program_type in [
LoadedProgramType::FailedVerification(cache.environments.program_runtime_v1.clone()),
LoadedProgramType::Closed,
LoadedProgramType::DelayVisibility,
LoadedProgramType::Unloaded(cache.environments.program_runtime_v1.clone()),
LoadedProgramType::Builtin(BuiltinProgram::new_mock()),
] {
assert!(LoadedProgram {
program: loaded_program_type,
account_size: 0,
deployment_slot: 0,
effective_slot: 0,
tx_usage_counter: AtomicU64::default(),
ix_usage_counter: AtomicU64::default(),
latest_access_slot: AtomicU64::default(),
}
.to_unloaded()
.is_none());
}

let unloaded_entry = new_test_loaded_program_with_usage(1, 2, AtomicU64::new(3))
.to_unloaded()
.unwrap();
assert_eq!(unloaded_entry.deployment_slot, 1);
assert_eq!(unloaded_entry.effective_slot, 2);
assert_eq!(unloaded_entry.latest_access_slot.load(Ordering::Relaxed), 1);
assert_eq!(unloaded_entry.tx_usage_counter.load(Ordering::Relaxed), 3);
}

#[test]
fn test_fork_prune_find_first_ancestor() {
let mut cache = new_mock_cache::<TestForkGraphSpecific>();
Expand Down

0 comments on commit 6491692

Please sign in to comment.