add AccountStorage.is_empty_entry for tests (#29489)

This commit is contained in:
Jeff Washington (jwash) 2023-01-03 14:36:31 -06:00 committed by GitHub
parent 0f2bfa2b02
commit 89deecb979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -59,6 +59,14 @@ impl AccountStorage {
.unwrap_or(true)
}
/// returns true if there is an entry in the map for 'slot', but it contains no append vec
#[cfg(test)]
pub(crate) fn is_empty_entry(&self, slot: Slot) -> bool {
self.get_slot_stores(slot)
.map(|storages| storages.read().unwrap().is_empty())
.unwrap_or(false)
}
/// initialize the storage map to 'all_storages'
pub(crate) fn initialize(&mut self, all_storages: AccountStorageMap) {
assert!(self.map.is_empty());

View File

@ -16509,7 +16509,7 @@ pub mod tests {
} else {
assert!(db.dirty_stores.is_empty());
}
assert!(db.get_storages_for_slot(slot).unwrap().is_empty());
assert!(db.storage.is_empty_entry(slot));
}
}
@ -17538,7 +17538,7 @@ pub mod tests {
&mut AncientSlotPubkeys::default(),
&mut dropped_roots,
);
assert!(db.get_storages_for_slot(next_slot).unwrap().is_empty());
assert!(db.storage.is_empty_entry(next_slot));
// this removes the storages entry completely from the hashmap for 'next_slot'.
// Otherwise, we have a zero length vec in that hashmap
db.handle_dropped_roots_for_ancient(dropped_roots);