From 3af306e0721d161a0ef8552299e3b1d3f355bc52 Mon Sep 17 00:00:00 2001 From: Brooks Date: Thu, 21 Dec 2023 10:54:36 -0500 Subject: [PATCH] Moves Bank tests-only ctors to DCOU (#34534) --- runtime/src/bank.rs | 64 ++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 7c785407a212eb..14643c3aa6d3b0 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -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; @@ -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, @@ -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, - ) -> 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(), @@ -1043,28 +1029,6 @@ impl Bank { bank } - pub fn new_with_paths_for_tests( - genesis_config: &GenesisConfig, - runtime_config: Arc, - paths: Vec, - 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, @@ -8232,6 +8196,28 @@ impl Bank { ) } + pub fn new_with_paths_for_tests( + genesis_config: &GenesisConfig, + runtime_config: Arc, + paths: Vec, + 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()) }