test_lazy_gc_slot can use write cache (#29080)

This commit is contained in:
Jeff Washington (jwash) 2022-12-05 14:48:15 -06:00 committed by GitHub
parent 8c47e2168e
commit 9746eb2c8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -11569,11 +11569,14 @@ pub mod tests {
//This test is pedantic //This test is pedantic
//A slot is purged when a non root bank is cleaned up. If a slot is behind root but it is //A slot is purged when a non root bank is cleaned up. If a slot is behind root but it is
//not root, it means we are retaining dead banks. //not root, it means we are retaining dead banks.
let accounts = AccountsDb::new(Vec::new(), &ClusterType::Development); let mut accounts = AccountsDb::new(Vec::new(), &ClusterType::Development);
accounts.caching_enabled = true;
let pubkey = solana_sdk::pubkey::new_rand(); let pubkey = solana_sdk::pubkey::new_rand();
let account = AccountSharedData::new(1, 0, AccountSharedData::default().owner()); let account = AccountSharedData::new(1, 0, AccountSharedData::default().owner());
//store an account //store an account
accounts.store_uncached(0, &[(&pubkey, &account)]); accounts.store_from_test(0, &[(&pubkey, &account)]);
accounts.add_root_and_flush_write_cache(0);
let ancestors = vec![(0, 0)].into_iter().collect(); let ancestors = vec![(0, 0)].into_iter().collect();
let id = { let id = {
let (lock, idx) = accounts let (lock, idx) = accounts
@ -11583,7 +11586,6 @@ pub mod tests {
lock.slot_list()[idx].1.store_id() lock.slot_list()[idx].1.store_id()
}; };
accounts.get_accounts_delta_hash(0); accounts.get_accounts_delta_hash(0);
accounts.add_root(1);
//slot is still there, since gc is lazy //slot is still there, since gc is lazy
assert!(accounts assert!(accounts
@ -11596,13 +11598,14 @@ pub mod tests {
.is_some()); .is_some());
//store causes clean //store causes clean
accounts.store_uncached(1, &[(&pubkey, &account)]); accounts.store_from_test(1, &[(&pubkey, &account)]);
// generate delta state for slot 1, so clean operates on it. // generate delta state for slot 1, so clean operates on it.
accounts.get_accounts_delta_hash(1); accounts.get_accounts_delta_hash(1);
//slot is gone //slot is gone
accounts.print_accounts_stats("pre-clean"); accounts.print_accounts_stats("pre-clean");
accounts.add_root_and_flush_write_cache(1);
accounts.clean_accounts_for_tests(); accounts.clean_accounts_for_tests();
assert!(accounts.storage.map.get(&0).is_none()); assert!(accounts.storage.map.get(&0).is_none());