Skip to content

Commit

Permalink
hot storage tests don't use Option
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Apr 15, 2024
1 parent 8890544 commit 9b0eb6b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
6 changes: 4 additions & 2 deletions accounts-db/src/tiered_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ mod tests {
storable_accounts.get(i, |(account, address, _account_hash)| {
expected_accounts_map.insert(
*address,
account.map(|account| account.to_account_shared_data()),
account
.map(|account| account.to_account_shared_data())
.unwrap_or_default(),
);
});
}
Expand All @@ -378,7 +380,7 @@ mod tests {
if let Some(account) = expected_accounts_map.get(stored_account_meta.pubkey()) {
verify_test_account_with_footer(
&stored_account_meta,
account.as_ref(),
account,
stored_account_meta.pubkey(),
footer,
);
Expand Down
24 changes: 21 additions & 3 deletions accounts-db/src/tiered_storage/hot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,13 @@ mod tests {
.unwrap();

storable_accounts.get(i, |(account, address, _account_hash)| {
verify_test_account(&stored_account_meta, account.as_ref(), address);
verify_test_account(
&stored_account_meta,
&account
.map(|account| account.to_account_shared_data())
.unwrap_or_default(),
address,
);
});

assert_eq!(i + 1, next.0 as usize);
Expand All @@ -1582,7 +1588,13 @@ mod tests {
.unwrap();

storable_accounts.get(stored_info.offset, |(account, address, _account_hash)| {
verify_test_account(&stored_account_meta, account.as_ref(), address);
verify_test_account(
&stored_account_meta,
&account
.map(|account| account.to_account_shared_data())
.unwrap_or_default(),
address,
);
});
}

Expand All @@ -1592,7 +1604,13 @@ mod tests {
// first, we verify everything
for (i, stored_meta) in accounts.iter().enumerate() {
storable_accounts.get(i, |(account, address, _account_hash)| {
verify_test_account(stored_meta, account.as_ref(), address);
verify_test_account(
stored_meta,
&account
.map(|account| account.to_account_shared_data())
.unwrap_or_default(),
address,
);
});
}

Expand Down
10 changes: 4 additions & 6 deletions accounts-db/src/tiered_storage/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use {
crate::{
account_storage::meta::{StoredAccountMeta, StoredMeta},
accounts_hash::AccountHash,
tiered_storage::owners::OWNER_NO_OWNER,
},
solana_sdk::{
account::{Account, AccountSharedData, ReadableAccount},
Expand Down Expand Up @@ -47,12 +46,11 @@ pub(super) fn create_test_account(seed: u64) -> (StoredMeta, AccountSharedData)

pub(super) fn verify_test_account(
stored_meta: &StoredAccountMeta<'_>,
account: Option<&impl ReadableAccount>,
acc: &impl ReadableAccount,
address: &Pubkey,
) {
let (lamports, owner, data, executable) = account
.map(|acc| (acc.lamports(), acc.owner(), acc.data(), acc.executable()))
.unwrap_or((0, &OWNER_NO_OWNER, &[], false));
let (lamports, owner, data, executable) =
(acc.lamports(), acc.owner(), acc.data(), acc.executable());

assert_eq!(stored_meta.lamports(), lamports);
assert_eq!(stored_meta.data().len(), data.len());
Expand All @@ -65,7 +63,7 @@ pub(super) fn verify_test_account(

pub(super) fn verify_test_account_with_footer(
stored_meta: &StoredAccountMeta<'_>,
account: Option<&impl ReadableAccount>,
account: &impl ReadableAccount,
address: &Pubkey,
footer: &TieredStorageFooter,
) {
Expand Down

0 comments on commit 9b0eb6b

Please sign in to comment.