Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Uses Bank::new_for_tests() instead of new_for_tests_with_config() #34587

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use {
AbsRequestHandlers, AbsRequestSender, AccountsBackgroundService, DroppedSlotsReceiver,
PrunedBanksRequestHandler, SnapshotRequestHandler,
},
bank::{epoch_accounts_hash_utils, Bank, BankTestConfig},
bank::{epoch_accounts_hash_utils, Bank},
bank_forks::BankForks,
genesis_utils::{self, GenesisConfigInfo},
runtime_config::RuntimeConfig,
Expand Down Expand Up @@ -113,10 +113,8 @@ impl TestEnvironment {
..snapshot_config
};

let bank_forks = BankForks::new_rw_arc(Bank::new_for_tests_with_config(
&genesis_config_info.genesis_config,
BankTestConfig::default(),
));
let bank_forks =
BankForks::new_rw_arc(Bank::new_for_tests(&genesis_config_info.genesis_config));
Comment on lines +116 to +117
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a function called Bank::new_with_bank_forks_for_tests that does exactly this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I have follow up PRs planned for more refactors to consolidate the constructors.

I prefer these simpler PR with a single change. It's easy to see they are all the same. And this is correct as is.

bank_forks
.write()
.unwrap()
Expand Down
14 changes: 4 additions & 10 deletions runtime/src/bank/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mod tests {
use {
crate::{
bank::{
epoch_accounts_hash_utils, test_utils as bank_test_utils, Bank, BankTestConfig,
EpochRewardStatus, StartBlockHeightAndRewards,
epoch_accounts_hash_utils, test_utils as bank_test_utils, Bank, EpochRewardStatus,
StartBlockHeightAndRewards,
},
genesis_utils::activate_all_features,
runtime_config::RuntimeConfig,
Expand Down Expand Up @@ -340,10 +340,7 @@ mod tests {
for epoch_reward_status_active in [None, Some(vec![]), Some(vec![sample_rewards])] {
let (genesis_config, _) = create_genesis_config(500);

let bank0 = Arc::new(Bank::new_for_tests_with_config(
&genesis_config,
BankTestConfig::default(),
));
let bank0 = Arc::new(Bank::new_for_tests(&genesis_config));
bank0.squash();
let mut bank = Bank::new_from_parent(bank0.clone(), &Pubkey::default(), 1);

Expand Down Expand Up @@ -533,10 +530,7 @@ mod tests {
solana_logger::setup();
let (genesis_config, _) = create_genesis_config(500);

let bank0 = Arc::new(Bank::new_for_tests_with_config(
&genesis_config,
BankTestConfig::default(),
));
let bank0 = Arc::new(Bank::new_for_tests(&genesis_config));
bank0.squash();
let mut bank = Bank::new_from_parent(bank0.clone(), &Pubkey::default(), 1);
add_root_and_flush_write_cache(&bank0);
Expand Down
17 changes: 5 additions & 12 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2130,8 +2130,7 @@ fn test_purge_empty_accounts() {
let (genesis_config, mint_keypair) = create_genesis_config(sol_to_lamports(1.));
let amount = genesis_config.rent.minimum_balance(0);
let (mut bank, bank_forks) =
Bank::new_for_tests_with_config(&genesis_config, BankTestConfig::default())
.wrap_with_bank_forks_for_tests();
Bank::new_for_tests(&genesis_config).wrap_with_bank_forks_for_tests();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bank::new_with_bank_forks_for_tests does this as well.


for _ in 0..10 {
let blockhash = bank.last_blockhash();
Expand Down Expand Up @@ -3769,10 +3768,7 @@ fn test_bank_update_sysvar_account() {
for feature_id in FeatureSet::default().inactive {
activate_feature(&mut genesis_config, feature_id);
}
let bank1 = Arc::new(Bank::new_for_tests_with_config(
&genesis_config,
BankTestConfig::default(),
));
let bank1 = Arc::new(Bank::new_for_tests(&genesis_config));
if pass == 0 {
add_root_and_flush_write_cache(&bank1);
assert_eq!(bank1.calculate_capitalization(true), bank1.capitalization());
Expand Down Expand Up @@ -6960,10 +6956,7 @@ fn test_add_precompiled_account() {
let program_id = solana_sdk::pubkey::new_rand();

let bank = Arc::new(Bank::new_from_parent(
Arc::new(Bank::new_for_tests_with_config(
&genesis_config,
BankTestConfig::default(),
)),
Arc::new(Bank::new_for_tests(&genesis_config)),
&Pubkey::default(),
slot,
));
Expand Down Expand Up @@ -7005,7 +6998,7 @@ fn test_add_precompiled_account_inherited_cap_while_replacing() {
// and then want to continue modifying the bank
for pass in 0..4 {
let (genesis_config, mint_keypair) = create_genesis_config(100_000);
let bank = Bank::new_for_tests_with_config(&genesis_config, BankTestConfig::default());
let bank = Bank::new_for_tests(&genesis_config);
let program_id = solana_sdk::pubkey::new_rand();

bank.add_precompiled_account(&program_id);
Expand Down Expand Up @@ -7039,7 +7032,7 @@ fn test_add_precompiled_account_inherited_cap_while_replacing() {
fn test_add_precompiled_account_squatted_while_not_replacing() {
for pass in 0..3 {
let (genesis_config, mint_keypair) = create_genesis_config(100_000);
let bank = Bank::new_for_tests_with_config(&genesis_config, BankTestConfig::default());
let bank = Bank::new_for_tests(&genesis_config);
let program_id = solana_sdk::pubkey::new_rand();

// someone managed to squat at program_id!
Expand Down