diff --git a/accounts-db/src/account_storage/meta.rs b/accounts-db/src/account_storage/meta.rs index 5f9ec647a4138d..445000a329e411 100644 --- a/accounts-db/src/account_storage/meta.rs +++ b/accounts-db/src/account_storage/meta.rs @@ -65,10 +65,10 @@ impl<'storage> StoredAccountMeta<'storage> { } } - pub fn data_len(&self) -> u64 { + pub fn data_len(&self) -> usize { match self { - Self::AppendVec(av) => av.data_len(), - Self::Hot(hot) => hot.data().len() as u64, + Self::AppendVec(av) => av.data_len() as usize, + Self::Hot(hot) => hot.data().len(), } } diff --git a/accounts-db/src/ancient_append_vecs.rs b/accounts-db/src/ancient_append_vecs.rs index 3260a89ce054b0..91fc25064fc9ae 100644 --- a/accounts-db/src/ancient_append_vecs.rs +++ b/accounts-db/src/ancient_append_vecs.rs @@ -1125,7 +1125,7 @@ pub mod tests { bytes: accounts .stored_accounts .iter() - .map(|account| aligned_stored_size(account.data().len())) + .map(|account| aligned_stored_size(account.data_len())) .sum(), slot, }) @@ -1317,7 +1317,7 @@ pub mod tests { bytes: accounts .stored_accounts .iter() - .map(|account| aligned_stored_size(account.data().len())) + .map(|account| aligned_stored_size(account.data_len())) .sum(), slot, }) @@ -1364,7 +1364,7 @@ pub mod tests { .iter() .map(|(_slot, accounts)| accounts .iter() - .map(|account| aligned_stored_size(account.data().len()) as u64) + .map(|account| aligned_stored_size(account.data_len()) as u64) .sum::()) .sum::() ); @@ -1665,8 +1665,9 @@ pub mod tests { .stored_accounts .first() .unwrap(); + let account_shared_data_with_2_refs = account_with_2_refs.to_account_shared_data(); let pk_with_2_refs = account_with_2_refs.pubkey(); - let mut account_with_1_ref = account_with_2_refs.to_account_shared_data(); + let mut account_with_1_ref = account_shared_data_with_2_refs.clone(); account_with_1_ref.checked_add_lamports(1).unwrap(); append_single_account_with_default_hash( &storage, @@ -1683,7 +1684,7 @@ pub mod tests { append_single_account_with_default_hash( &ignored_storage, pk_with_2_refs, - &account_with_2_refs.to_account_shared_data(), + &account_shared_data_with_2_refs, true, Some(&db.accounts_index), ); @@ -1731,6 +1732,11 @@ pub mod tests { .alive_accounts .one_ref .accounts; + let one_ref_accounts_account_shared_data = one_ref_accounts + .iter() + .map(|account| account.to_account_shared_data()) + .collect::>(); + assert_eq!( one_ref_accounts .iter() @@ -1739,7 +1745,7 @@ pub mod tests { vec![&pk_with_1_ref] ); assert_eq!( - one_ref_accounts + one_ref_accounts_account_shared_data .iter() .map(|meta| meta.to_account_shared_data()) .collect::>(), @@ -1815,7 +1821,7 @@ pub mod tests { .first() .unwrap() .to_account_shared_data(), - account_with_2_refs.to_account_shared_data() + account_shared_data_with_2_refs ); } } @@ -1843,8 +1849,9 @@ pub mod tests { .stored_accounts .first() .unwrap(); + let account_shared_data_with_2_refs = account_with_2_refs.to_account_shared_data(); let pk_with_2_refs = account_with_2_refs.pubkey(); - let mut account_with_1_ref = account_with_2_refs.to_account_shared_data(); + let mut account_with_1_ref = account_shared_data_with_2_refs.clone(); _ = account_with_1_ref.checked_add_lamports(1); append_single_account_with_default_hash( &storage, @@ -1906,6 +1913,10 @@ pub mod tests { .alive_accounts .one_ref .accounts; + let one_ref_accounts_account_shared_data = one_ref_accounts + .iter() + .map(|account| account.to_account_shared_data()) + .collect::>(); assert_eq!( one_ref_accounts .iter() @@ -1914,7 +1925,7 @@ pub mod tests { vec![&pk_with_1_ref] ); assert_eq!( - one_ref_accounts + one_ref_accounts_account_shared_data .iter() .map(|meta| meta.to_account_shared_data()) .collect::>(), @@ -1958,7 +1969,7 @@ pub mod tests { .first() .unwrap() .to_account_shared_data(), - account_with_2_refs.to_account_shared_data() + account_shared_data_with_2_refs ); } } diff --git a/accounts-db/src/append_vec.rs b/accounts-db/src/append_vec.rs index f0864fbf8787d4..1fdb99f60d1015 100644 --- a/accounts-db/src/append_vec.rs +++ b/accounts-db/src/append_vec.rs @@ -1263,7 +1263,7 @@ pub mod tests { // Reload accounts and observe crafted_data_len let accounts = av.accounts(0); let account = accounts.first().unwrap(); - assert_eq!(account.data_len(), crafted_data_len); + assert_eq!(account.data_len() as u64, crafted_data_len); av.flush().unwrap(); av.len() diff --git a/accounts-db/src/storable_accounts.rs b/accounts-db/src/storable_accounts.rs index 0fc3b3ad4f1c30..b988b5d014187d 100644 --- a/accounts-db/src/storable_accounts.rs +++ b/accounts-db/src/storable_accounts.rs @@ -514,9 +514,6 @@ pub mod tests { #[test] fn test_storable_accounts_by_slot() { - solana_logger::setup(); - // slots 0..4 - // each one containing a subset of the overall # of entries (0..4) for entries in 0..6 { let data = Vec::default(); let hashes = (0..entries)