Skip to content

Commit

Permalink
Moves Bank tests-only ctors to DCOU (solana-labs#34534)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Dec 21, 2023
1 parent f0ff69b commit 3af306e
Showing 1 changed file with 25 additions and 39 deletions.
64 changes: 25 additions & 39 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
//! on behalf of the caller, and a low-level API for when they have
//! already been signed and verified.
#[cfg(feature = "dev-context-only-utils")]
use solana_accounts_db::accounts_db::ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS;
use solana_accounts_db::accounts_db::{
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
};
#[allow(deprecated)]
use solana_sdk::recent_blockhashes_account;
pub use solana_sdk::reward_type::RewardType;
Expand Down Expand Up @@ -78,7 +80,6 @@ use {
accounts_db::{
AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AccountsDbConfig,
CalcAccountsHashDataSource, VerifyAccountsHashAndLamportsConfig,
ACCOUNTS_DB_CONFIG_FOR_TESTING,
},
accounts_hash::{
AccountHash, AccountsHash, CalcAccountsHashConfig, HashStats, IncrementalAccountsHash,
Expand Down Expand Up @@ -954,21 +955,6 @@ pub(super) enum RewardInterval {
}

impl Bank {
/// Intended for use by tests only.
/// create new bank with the given configs.
pub fn new_with_runtime_config_for_tests(
genesis_config: &GenesisConfig,
runtime_config: Arc<RuntimeConfig>,
) -> Self {
Self::new_with_paths_for_tests(
genesis_config,
runtime_config,
Vec::new(),
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
)
}

fn default_with_accounts(accounts: Accounts) -> Self {
let mut bank = Self {
skipped_rewrites: Mutex::default(),
Expand Down Expand Up @@ -1043,28 +1029,6 @@ impl Bank {
bank
}

pub fn new_with_paths_for_tests(
genesis_config: &GenesisConfig,
runtime_config: Arc<RuntimeConfig>,
paths: Vec<PathBuf>,
account_indexes: AccountSecondaryIndexes,
shrink_ratio: AccountShrinkThreshold,
) -> Self {
Self::new_with_paths(
genesis_config,
runtime_config,
paths,
None,
None,
account_indexes,
shrink_ratio,
false,
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
None,
Arc::default(),
)
}

#[allow(clippy::too_many_arguments)]
pub fn new_with_paths(
genesis_config: &GenesisConfig,
Expand Down Expand Up @@ -8232,6 +8196,28 @@ impl Bank {
)
}

pub fn new_with_paths_for_tests(
genesis_config: &GenesisConfig,
runtime_config: Arc<RuntimeConfig>,
paths: Vec<PathBuf>,
account_indexes: AccountSecondaryIndexes,
shrink_ratio: AccountShrinkThreshold,
) -> Self {
Self::new_with_paths(
genesis_config,
runtime_config,
paths,
None,
None,
account_indexes,
shrink_ratio,
false,
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
None,
Arc::default(),
)
}

pub fn new_for_benches(genesis_config: &GenesisConfig) -> Self {
Self::new_with_paths_for_benches(genesis_config, Vec::new())
}
Expand Down

0 comments on commit 3af306e

Please sign in to comment.