Bank::default_for_tests() (#19084)

This commit is contained in:
Jeff Washington (jwash) 2021-08-05 11:53:29 -05:00 committed by GitHub
parent 24207a09ac
commit a9014ceceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 7 deletions

View File

@ -106,7 +106,7 @@ mod tests {
#[test]
fn test_rpc_banks_server_exit() {
let bank_forks = Arc::new(RwLock::new(BankForks::new(Bank::default())));
let bank_forks = Arc::new(RwLock::new(BankForks::new(Bank::default_for_tests())));
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::default()));
let exit = Arc::new(AtomicBool::new(false));
let addr = "127.0.0.1:0".parse().unwrap();

View File

@ -189,7 +189,7 @@ mod test {
#[test]
fn service_exit() {
let tpu_address = "127.0.0.1:0".parse().unwrap();
let bank = Bank::default();
let bank = Bank::default_for_tests();
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
let (sender, receiver) = channel();

View File

@ -25,7 +25,7 @@ fn bench_save_tower(bench: &mut Bencher) {
let vote_account_pubkey = &Pubkey::default();
let node_keypair = Arc::new(Keypair::new());
let heaviest_bank = BankForks::new(Bank::default()).working_bank();
let heaviest_bank = BankForks::new(Bank::default_for_tests()).working_bank();
let tower = Tower::new(
&node_keypair.pubkey(),
vote_account_pubkey,
@ -47,7 +47,7 @@ fn bench_generate_ancestors_descendants(bench: &mut Bencher) {
let vote_account_pubkey = &Pubkey::default();
let node_keypair = Arc::new(Keypair::new());
let heaviest_bank = BankForks::new(Bank::default()).working_bank();
let heaviest_bank = BankForks::new(Bank::default_for_tests()).working_bank();
let mut tower = Tower::new(
&node_keypair.pubkey(),
vote_account_pubkey,

View File

@ -2101,7 +2101,7 @@ mod tests {
fn test_should_process_or_forward_packets() {
let my_pubkey = solana_sdk::pubkey::new_rand();
let my_pubkey1 = solana_sdk::pubkey::new_rand();
let bank = Arc::new(Bank::default());
let bank = Arc::new(Bank::default_for_tests());
assert_matches!(
BankingStage::consume_or_forward_packets(&my_pubkey, None, Some(&bank), false, false),
BufferedPacketsDecision::Hold

View File

@ -6854,7 +6854,7 @@ pub mod tests {
#[test]
fn test_is_finalized() {
let bank = Arc::new(Bank::default());
let bank = Arc::new(Bank::default_for_tests());
let ledger_path = get_tmp_ledger_path!();
let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap());
blockstore.set_roots(vec![0, 1].iter()).unwrap();

View File

@ -340,7 +340,7 @@ mod test {
#[test]
fn service_exit() {
let tpu_address = "127.0.0.1:0".parse().unwrap();
let bank = Bank::default();
let bank = Bank::default_for_tests();
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
let (sender, receiver) = channel();

View File

@ -1047,6 +1047,11 @@ impl Default for BlockhashQueue {
}
impl Bank {
pub fn default_for_tests() -> Self {
// will diverge
Self::default()
}
pub fn new_for_benches(genesis_config: &GenesisConfig) -> Self {
// this will diverge
Self::new_for_tests(genesis_config)