From 26472a13eab0f9c0f1d7b1e7aa5b03367c30d7a7 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 6 Dec 2022 12:25:37 -0600 Subject: [PATCH] migrating tests to use write cache (#29101) * test_account_update uses write cache * test_accounts_db_purge_keep_live works with write cache * enable caching for test_accounts_db_purge_keep_live --- runtime/src/accounts_db.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 2ae8115a91..fd96a8f422 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -11440,6 +11440,7 @@ pub mod tests { let mut pubkeys: Vec = vec![]; create_account(&accounts, &mut pubkeys, 0, 100, 0, 0); update_accounts(&accounts, &pubkeys, 0, 99); + accounts.add_root_and_flush_write_cache(0); assert!(check_storage(&accounts, 0, 100)); } @@ -12240,8 +12241,10 @@ pub mod tests { let zero_lamport_account = AccountSharedData::new(zero_lamport, no_data, &owner); - let accounts = AccountsDb::new_single_for_tests(); - accounts.add_root(0); + let mut accounts = AccountsDb::new_single_for_tests(); + accounts.caching_enabled = true; + accounts.get_accounts_delta_hash(0); + accounts.add_root_and_flush_write_cache(0); // Step A let mut current_slot = 1; @@ -12249,7 +12252,8 @@ pub mod tests { // Store another live account to slot 1 which will prevent any purge // since the store count will not be zero accounts.store_for_tests(current_slot, &[(&pubkey2, &account2)]); - accounts.add_root(current_slot); + accounts.get_accounts_delta_hash(current_slot); + accounts.add_root_and_flush_write_cache(current_slot); let (slot1, account_info1) = accounts .accounts_index .get_for_tests(&pubkey, None, None) @@ -12268,12 +12272,14 @@ pub mod tests { current_slot += 1; let zero_lamport_slot = current_slot; accounts.store_for_tests(current_slot, &[(&pubkey, &zero_lamport_account)]); - accounts.add_root(current_slot); + accounts.get_accounts_delta_hash(current_slot); + accounts.add_root_and_flush_write_cache(current_slot); assert_load_account(&accounts, current_slot, pubkey, zero_lamport); current_slot += 1; - accounts.add_root(current_slot); + accounts.get_accounts_delta_hash(current_slot); + accounts.add_root_and_flush_write_cache(current_slot); accounts.print_accounts_stats("pre_purge");