Skip to content

Commit

Permalink
Enable accountsdb_scan_account_storage_no_bank tests for hot storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhchiang-sol committed Mar 27, 2024
1 parent 329edc7 commit bdba36e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,15 +1030,15 @@ pub struct AccountStorageEntry {
}

impl AccountStorageEntry {
pub fn new<AFP: AccountsFileProvider>(
pub fn new<AP: AccountsFileProvider>(
path: &Path,
slot: Slot,
id: AccountsFileId,
file_size: u64,
) -> Self {
let tail = AccountsFile::file_name(slot, id);
let path = Path::new(path).join(tail);
let accounts = AFP::new_writable(path, file_size);
let accounts = AP::new_writable(path, file_size);

Self {
id,
Expand Down Expand Up @@ -9509,6 +9509,7 @@ pub mod tests {
crate::{
account_info::StoredSize,
account_storage::meta::{AccountMeta, StoredMeta},
accounts_file::{AppendVecProvider, HotStorageProvider},
accounts_hash::MERKLE_FANOUT,
accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude},
ancient_append_vecs,
Expand Down Expand Up @@ -10592,8 +10593,11 @@ pub mod tests {
}
}

#[test]
fn test_accountsdb_scan_account_storage_no_bank() {
#[test_case(AppendVecProvider; "append_vec")]
#[test_case(HotStorageProvider; "hot_storage")]
fn test_accountsdb_scan_account_storage_no_bank<AP: AccountsFileProvider>(
_accounts_file_provider: AP,
) {
solana_logger::setup();

let expected = 1;
Expand All @@ -10603,10 +10607,9 @@ pub mod tests {
let (_temp_dirs, paths) = get_temp_accounts_paths(1).unwrap();
let slot_expected: Slot = 0;
let size: usize = 123;
let mut data =
AccountStorageEntry::new::<AppendVecProvider>(&paths[0], slot_expected, 0, size as u64);
let av = AccountsFile::AppendVec(AppendVec::new(&tf.path, true, 1024 * 1024));
data.accounts = av;
let mut data = AccountStorageEntry::new::<AP>(&paths[0], slot_expected, 0, size as u64);
let accounts_file = AP::new_writable(&tf.path, 1024 * 1024);
data.accounts = accounts_file;

let storage = Arc::new(data);
let pubkey = solana_sdk::pubkey::new_rand();
Expand Down Expand Up @@ -10709,21 +10712,23 @@ pub mod tests {
}
}

#[test]
fn test_accountsdb_scan_account_storage_no_bank_one_slot() {
#[test_case(AppendVecProvider; "append_vec")]
#[test_case(HotStorageProvider; "hot_storage")]
fn test_accountsdb_scan_account_storage_no_bank_one_slot<AP: AccountsFileProvider>(
_accounts_file_provider: AP,
) {
solana_logger::setup();

let expected = 1;
let tf = crate::append_vec::test_utils::get_append_vec_path(
"test_accountsdb_scan_account_storage_no_bank",
"test_accountsdb_scan_account_storage_no_bank_one_slot",
);
let (_temp_dirs, paths) = get_temp_accounts_paths(1).unwrap();
let slot_expected: Slot = 0;
let size: usize = 123;
let mut data =
AccountStorageEntry::new::<AppendVecProvider>(&paths[0], slot_expected, 0, size as u64);
let av = AccountsFile::AppendVec(AppendVec::new(&tf.path, true, 1024 * 1024));
data.accounts = av;
let mut data = AccountStorageEntry::new::<AP>(&paths[0], slot_expected, 0, size as u64);
let accounts_file = AP::new_writable(&tf.path, 1024 * 1024);
data.accounts = accounts_file;

let storage = Arc::new(data);
let pubkey = solana_sdk::pubkey::new_rand();
Expand Down

0 comments on commit bdba36e

Please sign in to comment.