move bank test fn to its test_utils mod (#24171)

This commit is contained in:
HaoranYi 2022-04-11 10:42:24 -05:00 committed by GitHub
parent f8628d39e0
commit e14933c54d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -6,7 +6,11 @@ extern crate test;
use {
log::*,
solana_program_runtime::invoke_context::InvokeContext,
solana_runtime::{bank::*, bank_client::BankClient, loader_utils::create_invoke_instruction},
solana_runtime::{
bank::{test_utils::goto_end_of_slot, *},
bank_client::BankClient,
loader_utils::create_invoke_instruction,
},
solana_sdk::{
client::{AsyncClient, SyncClient},
clock::MAX_RECENT_BLOCKHASHES,

View File

@ -6811,14 +6811,18 @@ impl Drop for Bank {
}
}
pub fn goto_end_of_slot(bank: &mut Bank) {
let mut tick_hash = bank.last_blockhash();
loop {
tick_hash = hashv(&[tick_hash.as_ref(), &[42]]);
bank.register_tick(&tick_hash);
if tick_hash == bank.last_blockhash() {
bank.freeze();
return;
/// utility function used for testing and benchmarking.
pub mod test_utils {
use {super::Bank, solana_sdk::hash::hashv};
pub fn goto_end_of_slot(bank: &mut Bank) {
let mut tick_hash = bank.last_blockhash();
loop {
tick_hash = hashv(&[tick_hash.as_ref(), &[42]]);
bank.register_tick(&tick_hash);
if tick_hash == bank.last_blockhash() {
bank.freeze();
return;
}
}
}
}
@ -6880,6 +6884,7 @@ pub(crate) mod tests {
},
},
std::{result, thread::Builder, time::Duration},
test_utils::goto_end_of_slot,
};
fn new_sanitized_message(