Skip to content

Commit

Permalink
add test method assert_no_storages_at_slot() (solana-labs#29483)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored and gnapoli23 committed Jan 10, 2023
1 parent cfd121c commit 62f0e4b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15129,7 +15129,7 @@ pub mod tests {
db.clean_accounts(Some(2), false, None);

// No stores should exist for slot 0 after clean
assert!(db.storage.get_slot_storage_entries(0).is_none());
assert_no_storages_at_slot(&db, 0);

// Ref count for `account_key1` (account removed earlier by shrink)
// should be 1, since it was only stored in slot 0 and 1, and slot 0
Expand Down Expand Up @@ -15651,7 +15651,7 @@ pub mod tests {
// cache, storage, and index

for (slot, _) in slots_to_dump {
assert!(db.storage.get_slot_storage_entries(*slot).is_none());
assert_no_storages_at_slot(&db, *slot);
assert!(db.accounts_cache.slot_cache(*slot).is_none());
let account_in_slot = slot_to_pubkey_map[slot];
let item = db.accounts_index.get_account_read_entry(&account_in_slot);
Expand Down Expand Up @@ -16033,7 +16033,12 @@ pub mod tests {
.accounts_index
.get_account_read_entry(&shared_key)
.is_none());
assert!(accounts.storage.get_slot_storage_entries(slot0).is_none());
assert_no_storages_at_slot(&accounts, slot0);
}

/// asserts that not only are there 0 append vecs, but there is not even an entry in the storage map for 'slot'
fn assert_no_storages_at_slot(db: &AccountsDb, slot: Slot) {
assert!(db.storage.get_slot_storage_entries(slot).is_none());
}

/// Test to make sure `clean_accounts()` works properly with the `last_full_snapshot_slot`
Expand Down

0 comments on commit 62f0e4b

Please sign in to comment.