rename process_entries to indicate it's only for tests (#21321)

This commit is contained in:
Justin Starry 2021-11-17 20:53:40 +01:00 committed by GitHub
parent 0f69a14247
commit 66fa062f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 21 deletions

View File

@ -11,7 +11,7 @@ use solana_core::banking_stage::{BankingStage, BankingStageStats};
use solana_entry::entry::{next_hash, Entry}; use solana_entry::entry::{next_hash, Entry};
use solana_gossip::cluster_info::ClusterInfo; use solana_gossip::cluster_info::ClusterInfo;
use solana_gossip::cluster_info::Node; use solana_gossip::cluster_info::Node;
use solana_ledger::blockstore_processor::process_entries; use solana_ledger::blockstore_processor::process_entries_for_tests;
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}; use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
use solana_perf::packet::to_packets_chunked; use solana_perf::packet::to_packets_chunked;
@ -321,7 +321,7 @@ fn simulate_process_entries(
hash: next_hash(&bank.last_blockhash(), 1, &tx_vector), hash: next_hash(&bank.last_blockhash(), 1, &tx_vector),
transactions: tx_vector, transactions: tx_vector,
}; };
process_entries(&bank, vec![entry], randomize_txs, None, None).unwrap(); process_entries_for_tests(&bank, vec![entry], randomize_txs, None, None).unwrap();
} }
#[allow(clippy::same_item_push)] #[allow(clippy::same_item_push)]

View File

@ -291,7 +291,7 @@ fn execute_batches(
/// 2. Process the locked group in parallel /// 2. Process the locked group in parallel
/// 3. Register the `Tick` if it's available /// 3. Register the `Tick` if it's available
/// 4. Update the leader scheduler, goto 1 /// 4. Update the leader scheduler, goto 1
pub fn process_entries( pub fn process_entries_for_tests(
bank: &Arc<Bank>, bank: &Arc<Bank>,
entries: Vec<Entry>, entries: Vec<Entry>,
randomize: bool, randomize: bool,
@ -2170,7 +2170,7 @@ pub mod tests {
); );
// Now ensure the TX is accepted despite pointing to the ID of an empty entry. // Now ensure the TX is accepted despite pointing to the ID of an empty entry.
process_entries(&bank, slot_entries, true, None, None).unwrap(); process_entries_for_tests(&bank, slot_entries, true, None, None).unwrap();
assert_eq!(bank.process_transaction(&tx), Ok(())); assert_eq!(bank.process_transaction(&tx), Ok(()));
} }
@ -2377,7 +2377,10 @@ pub mod tests {
// ensure bank can process a tick // ensure bank can process a tick
assert_eq!(bank.tick_height(), 0); assert_eq!(bank.tick_height(), 0);
let tick = next_entry(&genesis_config.hash(), 1, vec![]); let tick = next_entry(&genesis_config.hash(), 1, vec![]);
assert_eq!(process_entries(&bank, vec![tick], true, None, None), Ok(())); assert_eq!(
process_entries_for_tests(&bank, vec![tick], true, None, None),
Ok(())
);
assert_eq!(bank.tick_height(), 1); assert_eq!(bank.tick_height(), 1);
} }
@ -2410,7 +2413,7 @@ pub mod tests {
); );
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]); let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
assert_eq!( assert_eq!(
process_entries(&bank, vec![entry_1, entry_2], true, None, None), process_entries_for_tests(&bank, vec![entry_1, entry_2], true, None, None),
Ok(()) Ok(())
); );
assert_eq!(bank.get_balance(&keypair1.pubkey()), 2); assert_eq!(bank.get_balance(&keypair1.pubkey()), 2);
@ -2466,7 +2469,7 @@ pub mod tests {
); );
assert_eq!( assert_eq!(
process_entries( process_entries_for_tests(
&bank, &bank,
vec![entry_1_to_mint, entry_2_to_3_mint_to_1], vec![entry_1_to_mint, entry_2_to_3_mint_to_1],
false, false,
@ -2538,7 +2541,7 @@ pub mod tests {
], ],
); );
assert!(process_entries( assert!(process_entries_for_tests(
&bank, &bank,
vec![entry_1_to_mint.clone(), entry_2_to_3_mint_to_1.clone()], vec![entry_1_to_mint.clone(), entry_2_to_3_mint_to_1.clone()],
false, false,
@ -2646,7 +2649,7 @@ pub mod tests {
// keypair2=3 // keypair2=3
// keypair3=3 // keypair3=3
assert!(process_entries( assert!(process_entries_for_tests(
&bank, &bank,
vec![ vec![
entry_1_to_mint, entry_1_to_mint,
@ -2703,7 +2706,7 @@ pub mod tests {
system_transaction::transfer(&keypair2, &keypair4.pubkey(), 1, bank.last_blockhash()); system_transaction::transfer(&keypair2, &keypair4.pubkey(), 1, bank.last_blockhash());
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]); let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
assert_eq!( assert_eq!(
process_entries(&bank, vec![entry_1, entry_2], true, None, None), process_entries_for_tests(&bank, vec![entry_1, entry_2], true, None, None),
Ok(()) Ok(())
); );
assert_eq!(bank.get_balance(&keypair3.pubkey()), 1); assert_eq!(bank.get_balance(&keypair3.pubkey()), 1);
@ -2763,7 +2766,10 @@ pub mod tests {
next_entry_mut(&mut hash, 0, transactions) next_entry_mut(&mut hash, 0, transactions)
}) })
.collect(); .collect();
assert_eq!(process_entries(&bank, entries, true, None, None), Ok(())); assert_eq!(
process_entries_for_tests(&bank, entries, true, None, None),
Ok(())
);
} }
#[test] #[test]
@ -2824,7 +2830,7 @@ pub mod tests {
// Transfer lamports to each other // Transfer lamports to each other
let entry = next_entry(&bank.last_blockhash(), 1, tx_vector); let entry = next_entry(&bank.last_blockhash(), 1, tx_vector);
assert_eq!( assert_eq!(
process_entries(&bank, vec![entry], true, None, None), process_entries_for_tests(&bank, vec![entry], true, None, None),
Ok(()) Ok(())
); );
bank.squash(); bank.squash();
@ -2884,7 +2890,7 @@ pub mod tests {
system_transaction::transfer(&keypair1, &keypair4.pubkey(), 1, bank.last_blockhash()); system_transaction::transfer(&keypair1, &keypair4.pubkey(), 1, bank.last_blockhash());
let entry_2 = next_entry(&tick.hash, 1, vec![tx]); let entry_2 = next_entry(&tick.hash, 1, vec![tx]);
assert_eq!( assert_eq!(
process_entries( process_entries_for_tests(
&bank, &bank,
vec![entry_1, tick, entry_2.clone()], vec![entry_1, tick, entry_2.clone()],
true, true,
@ -2901,7 +2907,7 @@ pub mod tests {
system_transaction::transfer(&keypair2, &keypair3.pubkey(), 1, bank.last_blockhash()); system_transaction::transfer(&keypair2, &keypair3.pubkey(), 1, bank.last_blockhash());
let entry_3 = next_entry(&entry_2.hash, 1, vec![tx]); let entry_3 = next_entry(&entry_2.hash, 1, vec![tx]);
assert_eq!( assert_eq!(
process_entries(&bank, vec![entry_3], true, None, None), process_entries_for_tests(&bank, vec![entry_3], true, None, None),
Err(TransactionError::AccountNotFound) Err(TransactionError::AccountNotFound)
); );
} }
@ -2981,7 +2987,7 @@ pub mod tests {
); );
assert_eq!( assert_eq!(
process_entries(&bank, vec![entry_1_to_mint], false, None, None), process_entries_for_tests(&bank, vec![entry_1_to_mint], false, None, None),
Err(TransactionError::AccountInUse) Err(TransactionError::AccountInUse)
); );
@ -3283,7 +3289,7 @@ pub mod tests {
}) })
.collect(); .collect();
info!("paying iteration {}", i); info!("paying iteration {}", i);
process_entries(&bank, entries, true, None, None).expect("paying failed"); process_entries_for_tests(&bank, entries, true, None, None).expect("paying failed");
let entries: Vec<_> = (0..NUM_TRANSFERS) let entries: Vec<_> = (0..NUM_TRANSFERS)
.step_by(NUM_TRANSFERS_PER_ENTRY) .step_by(NUM_TRANSFERS_PER_ENTRY)
@ -3306,10 +3312,10 @@ pub mod tests {
.collect(); .collect();
info!("refunding iteration {}", i); info!("refunding iteration {}", i);
process_entries(&bank, entries, true, None, None).expect("refunding failed"); process_entries_for_tests(&bank, entries, true, None, None).expect("refunding failed");
// advance to next block // advance to next block
process_entries( process_entries_for_tests(
&bank, &bank,
(0..bank.ticks_per_slot()) (0..bank.ticks_per_slot())
.map(|_| next_entry_mut(&mut hash, 1, vec![])) .map(|_| next_entry_mut(&mut hash, 1, vec![]))
@ -3359,7 +3365,7 @@ pub mod tests {
let entry = next_entry(&new_blockhash, 1, vec![tx]); let entry = next_entry(&new_blockhash, 1, vec![tx]);
entries.push(entry); entries.push(entry);
process_entries(&bank0, entries, true, None, None).unwrap(); process_entries_for_tests(&bank0, entries, true, None, None).unwrap();
assert_eq!(bank0.get_balance(&keypair.pubkey()), 1) assert_eq!(bank0.get_balance(&keypair.pubkey()), 1)
} }
@ -3529,7 +3535,8 @@ pub mod tests {
.collect(); .collect();
let entry = next_entry(&bank_1_blockhash, 1, vote_txs); let entry = next_entry(&bank_1_blockhash, 1, vote_txs);
let (replay_vote_sender, replay_vote_receiver) = unbounded(); let (replay_vote_sender, replay_vote_receiver) = unbounded();
let _ = process_entries(&bank1, vec![entry], true, None, Some(&replay_vote_sender)); let _ =
process_entries_for_tests(&bank1, vec![entry], true, None, Some(&replay_vote_sender));
let successes: BTreeSet<Pubkey> = replay_vote_receiver let successes: BTreeSet<Pubkey> = replay_vote_receiver
.try_iter() .try_iter()
.map(|(vote_pubkey, _, _)| vote_pubkey) .map(|(vote_pubkey, _, _)| vote_pubkey)

View File

@ -4268,7 +4268,7 @@ pub fn create_test_transactions_and_populate_blockstore(
// Check that process_entries successfully writes can_commit transactions statuses, and // Check that process_entries successfully writes can_commit transactions statuses, and
// that they are matched properly by get_rooted_block // that they are matched properly by get_rooted_block
let _result = solana_ledger::blockstore_processor::process_entries( let _result = solana_ledger::blockstore_processor::process_entries_for_tests(
&bank, &bank,
entries, entries,
true, true,