Replaces ReadAccountMapEntry in more tests (#35308)
This commit is contained in:
parent
ec63b813f5
commit
58c1b7aefb
|
@ -9771,9 +9771,7 @@ pub mod tests {
|
|||
account_info::StoredSize,
|
||||
account_storage::meta::{AccountMeta, StoredMeta},
|
||||
accounts_hash::MERKLE_FANOUT,
|
||||
accounts_index::{
|
||||
tests::*, AccountSecondaryIndexesIncludeExclude, ReadAccountMapEntry, RefCount,
|
||||
},
|
||||
accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude},
|
||||
ancient_append_vecs,
|
||||
append_vec::{test_utils::TempFile, AppendVecStoredAccountMeta},
|
||||
cache_hash_data::CacheHashDataFile,
|
||||
|
@ -13366,22 +13364,10 @@ pub mod tests {
|
|||
|
||||
const UPSERT_POPULATE_RECLAIMS: UpsertReclaim = UpsertReclaim::PopulateReclaims;
|
||||
|
||||
// returns the rooted entries and the storage ref count
|
||||
fn roots_and_ref_count<T: IndexValue>(
|
||||
index: &AccountsIndex<T, T>,
|
||||
locked_account_entry: &ReadAccountMapEntry<T>,
|
||||
max_inclusive: Option<Slot>,
|
||||
) -> (SlotList<T>, RefCount) {
|
||||
(
|
||||
index.get_rooted_entries(locked_account_entry.slot_list(), max_inclusive),
|
||||
locked_account_entry.ref_count(),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_dependencies() {
|
||||
solana_logger::setup();
|
||||
let accounts_index = AccountsIndex::default_for_tests();
|
||||
let accounts_index = AccountsIndex::<AccountInfo, AccountInfo>::default_for_tests();
|
||||
let key0 = Pubkey::new_from_array([0u8; 32]);
|
||||
let key1 = Pubkey::new_from_array([1u8; 32]);
|
||||
let key2 = Pubkey::new_from_array([2u8; 32]);
|
||||
|
@ -13455,21 +13441,13 @@ pub mod tests {
|
|||
accounts_index.add_root(2);
|
||||
accounts_index.add_root(3);
|
||||
let mut purges = HashMap::new();
|
||||
let (key0_entry, _) = accounts_index.get_for_tests(&key0, None, None).unwrap();
|
||||
purges.insert(
|
||||
key0,
|
||||
roots_and_ref_count(&accounts_index, &key0_entry, None),
|
||||
);
|
||||
let (key1_entry, _) = accounts_index.get_for_tests(&key1, None, None).unwrap();
|
||||
purges.insert(
|
||||
key1,
|
||||
roots_and_ref_count(&accounts_index, &key1_entry, None),
|
||||
);
|
||||
let (key2_entry, _) = accounts_index.get_for_tests(&key2, None, None).unwrap();
|
||||
purges.insert(
|
||||
key2,
|
||||
roots_and_ref_count(&accounts_index, &key2_entry, None),
|
||||
);
|
||||
for key in [&key0, &key1, &key2] {
|
||||
let index_entry = accounts_index.get_cloned(key).unwrap();
|
||||
let rooted_entries = accounts_index
|
||||
.get_rooted_entries(index_entry.slot_list.read().unwrap().as_slice(), None);
|
||||
let ref_count = index_entry.ref_count();
|
||||
purges.insert(*key, (rooted_entries, ref_count));
|
||||
}
|
||||
for (key, (list, ref_count)) in &purges {
|
||||
info!(" purge {} ref_count {} =>", key, ref_count);
|
||||
for x in list {
|
||||
|
|
|
@ -2333,24 +2333,11 @@ pub mod tests {
|
|||
index.insert_new_if_missing_into_primary_index(slot, items.len(), items.into_iter());
|
||||
assert_eq!(result.count, 1);
|
||||
index.set_startup(Startup::Normal);
|
||||
if let AccountIndexGetResult::Found(entry, index) =
|
||||
// the entry for
|
||||
index.get_for_tests(pubkey, Some(&ancestors), None)
|
||||
{
|
||||
// make sure the one with the correct info is added
|
||||
assert_eq!(entry.slot_list()[index], (slot, account_info2));
|
||||
// make sure it wasn't inserted twice
|
||||
assert_eq!(
|
||||
entry
|
||||
.slot_list()
|
||||
.iter()
|
||||
.filter_map(|(entry_slot, _)| (entry_slot == &slot).then_some(true))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
} else {
|
||||
panic!("failed");
|
||||
}
|
||||
let index_entry = index.get_cloned(pubkey).unwrap();
|
||||
let slot_list = index_entry.slot_list.read().unwrap();
|
||||
// make sure the one with the correct info is added, and wasn't inserted twice
|
||||
assert_eq!(slot_list.len(), 1);
|
||||
assert_eq!(slot_list[0], (slot, account_info2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in New Issue