move test fn into its own mod (#24212)
* move test fn into its own mod * pub
This commit is contained in:
parent
474080608a
commit
605036c117
@ -6,7 +6,10 @@ use {
|
|||||||
rayon::prelude::*,
|
rayon::prelude::*,
|
||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
accounts::{create_test_accounts, update_accounts_bench, Accounts},
|
accounts::{
|
||||||
|
test_utils::{create_test_accounts, update_accounts_bench},
|
||||||
|
Accounts,
|
||||||
|
},
|
||||||
accounts_db::AccountShrinkThreshold,
|
accounts_db::AccountShrinkThreshold,
|
||||||
accounts_index::AccountSecondaryIndexes,
|
accounts_index::AccountSecondaryIndexes,
|
||||||
ancestors::Ancestors,
|
ancestors::Ancestors,
|
||||||
|
@ -8,7 +8,7 @@ use {
|
|||||||
rand::Rng,
|
rand::Rng,
|
||||||
rayon::iter::{IntoParallelRefIterator, ParallelIterator},
|
rayon::iter::{IntoParallelRefIterator, ParallelIterator},
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
accounts::{create_test_accounts, AccountAddressFilter, Accounts},
|
accounts::{test_utils::create_test_accounts, AccountAddressFilter, Accounts},
|
||||||
accounts_db::AccountShrinkThreshold,
|
accounts_db::AccountShrinkThreshold,
|
||||||
accounts_index::{AccountSecondaryIndexes, ScanConfig},
|
accounts_index::{AccountSecondaryIndexes, ScanConfig},
|
||||||
ancestors::Ancestors,
|
ancestors::Ancestors,
|
||||||
|
@ -1311,28 +1311,33 @@ pub fn prepare_if_nonce_account<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_test_accounts(
|
/// A set of utility functions used for testing and benchmarking
|
||||||
accounts: &Accounts,
|
pub mod test_utils {
|
||||||
pubkeys: &mut Vec<Pubkey>,
|
use super::*;
|
||||||
num: usize,
|
|
||||||
slot: Slot,
|
|
||||||
) {
|
|
||||||
for t in 0..num {
|
|
||||||
let pubkey = solana_sdk::pubkey::new_rand();
|
|
||||||
let account =
|
|
||||||
AccountSharedData::new((t + 1) as u64, 0, AccountSharedData::default().owner());
|
|
||||||
accounts.store_slow_uncached(slot, &pubkey, &account);
|
|
||||||
pubkeys.push(pubkey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only used by bench, not safe to call otherwise accounts can conflict with the
|
pub fn create_test_accounts(
|
||||||
// accounts cache!
|
accounts: &Accounts,
|
||||||
pub fn update_accounts_bench(accounts: &Accounts, pubkeys: &[Pubkey], slot: u64) {
|
pubkeys: &mut Vec<Pubkey>,
|
||||||
for pubkey in pubkeys {
|
num: usize,
|
||||||
let amount = thread_rng().gen_range(0, 10);
|
slot: Slot,
|
||||||
let account = AccountSharedData::new(amount, 0, AccountSharedData::default().owner());
|
) {
|
||||||
accounts.store_slow_uncached(slot, pubkey, &account);
|
for t in 0..num {
|
||||||
|
let pubkey = solana_sdk::pubkey::new_rand();
|
||||||
|
let account =
|
||||||
|
AccountSharedData::new((t + 1) as u64, 0, AccountSharedData::default().owner());
|
||||||
|
accounts.store_slow_uncached(slot, &pubkey, &account);
|
||||||
|
pubkeys.push(pubkey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only used by bench, not safe to call otherwise accounts can conflict with the
|
||||||
|
// accounts cache!
|
||||||
|
pub fn update_accounts_bench(accounts: &Accounts, pubkeys: &[Pubkey], slot: u64) {
|
||||||
|
for pubkey in pubkeys {
|
||||||
|
let amount = thread_rng().gen_range(0, 10);
|
||||||
|
let account = AccountSharedData::new(amount, 0, AccountSharedData::default().owner());
|
||||||
|
accounts.store_slow_uncached(slot, pubkey, &account);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
use {
|
use {
|
||||||
super::*,
|
super::*,
|
||||||
crate::{
|
crate::{
|
||||||
accounts::{create_test_accounts, Accounts},
|
accounts::{test_utils::create_test_accounts, Accounts},
|
||||||
accounts_db::{get_temp_accounts_paths, AccountShrinkThreshold},
|
accounts_db::{get_temp_accounts_paths, AccountShrinkThreshold},
|
||||||
bank::{Bank, StatusCacheRc},
|
bank::{Bank, StatusCacheRc},
|
||||||
hardened_unpack::UnpackedAppendVecMap,
|
hardened_unpack::UnpackedAppendVecMap,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user