AcctIdx: stats are usize (#21493)
* AcctIdx: stats are usize * rename test function
This commit is contained in:
committed by
GitHub
parent
38fcfb7542
commit
7ec88226ee
@@ -3052,10 +3052,10 @@ pub mod tests {
|
||||
|
||||
let new_entry =
|
||||
PreAllocatedAccountMapEntry::new(slot, account_info, &index.storage.storage, false);
|
||||
assert_eq!(0, account_maps_len_expensive(&index));
|
||||
assert_eq!(0, account_maps_stats_len(&index));
|
||||
assert_eq!((slot, account_info), new_entry.clone().into());
|
||||
|
||||
assert_eq!(0, account_maps_len_expensive(&index));
|
||||
assert_eq!(0, account_maps_stats_len(&index));
|
||||
let w_account_maps = index.get_account_maps_write_lock(&key.pubkey());
|
||||
w_account_maps.upsert(
|
||||
&key.pubkey(),
|
||||
@@ -3064,7 +3064,7 @@ pub mod tests {
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
drop(w_account_maps);
|
||||
assert_eq!(1, account_maps_len_expensive(&index));
|
||||
assert_eq!(1, account_maps_stats_len(&index));
|
||||
|
||||
let mut ancestors = Ancestors::default();
|
||||
assert!(index.get(&key.pubkey(), Some(&ancestors), None).is_none());
|
||||
@@ -3615,12 +3615,8 @@ pub mod tests {
|
||||
assert!(found_key);
|
||||
}
|
||||
|
||||
fn account_maps_len_expensive<T: IndexValue>(index: &AccountsIndex<T>) -> usize {
|
||||
index
|
||||
.account_maps
|
||||
.iter()
|
||||
.map(|bin_map| bin_map.read().unwrap().len())
|
||||
.sum()
|
||||
fn account_maps_stats_len<T: IndexValue>(index: &AccountsIndex<T>) -> usize {
|
||||
index.storage.storage.stats.total_count()
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3628,7 +3624,7 @@ pub mod tests {
|
||||
let key = Keypair::new();
|
||||
let index = AccountsIndex::<u64>::default_for_tests();
|
||||
let mut gc = Vec::new();
|
||||
assert_eq!(0, account_maps_len_expensive(&index));
|
||||
assert_eq!(0, account_maps_stats_len(&index));
|
||||
index.upsert(
|
||||
1,
|
||||
&key.pubkey(),
|
||||
@@ -3639,7 +3635,7 @@ pub mod tests {
|
||||
&mut gc,
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
assert_eq!(1, account_maps_len_expensive(&index));
|
||||
assert_eq!(1, account_maps_stats_len(&index));
|
||||
|
||||
index.upsert(
|
||||
1,
|
||||
@@ -3651,7 +3647,7 @@ pub mod tests {
|
||||
&mut gc,
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
assert_eq!(1, account_maps_len_expensive(&index));
|
||||
assert_eq!(1, account_maps_stats_len(&index));
|
||||
|
||||
let purges = index.purge_roots(&key.pubkey());
|
||||
assert_eq!(purges, (vec![], false));
|
||||
@@ -3660,7 +3656,7 @@ pub mod tests {
|
||||
let purges = index.purge_roots(&key.pubkey());
|
||||
assert_eq!(purges, (vec![(1, 10)], true));
|
||||
|
||||
assert_eq!(1, account_maps_len_expensive(&index));
|
||||
assert_eq!(1, account_maps_stats_len(&index));
|
||||
index.upsert(
|
||||
1,
|
||||
&key.pubkey(),
|
||||
@@ -3671,7 +3667,7 @@ pub mod tests {
|
||||
&mut gc,
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
assert_eq!(1, account_maps_len_expensive(&index));
|
||||
assert_eq!(1, account_maps_stats_len(&index));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user