Optimize test_recovery_with_expanded_coding_shreds (#20849)
This commit is contained in:
parent
f0de3e9bf0
commit
4642a2c856
|
@ -52,11 +52,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{blockstore::MAX_DATA_SHREDS_PER_SLOT, erasure::Session},
|
crate::{blockstore::MAX_DATA_SHREDS_PER_SLOT, erasure::Session},
|
||||||
bincode::config::Options,
|
bincode::config::Options,
|
||||||
rayon::{
|
rayon::{prelude::*, ThreadPool},
|
||||||
iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator},
|
|
||||||
slice::ParallelSlice,
|
|
||||||
ThreadPool,
|
|
||||||
},
|
|
||||||
serde::{Deserialize, Serialize},
|
serde::{Deserialize, Serialize},
|
||||||
solana_entry::entry::{create_ticks, Entry},
|
solana_entry::entry::{create_ticks, Entry},
|
||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
|
@ -1657,12 +1653,19 @@ pub mod tests {
|
||||||
fn run_recovery_with_expanded_coding_shreds(num_tx: usize, is_last_in_slot: bool) {
|
fn run_recovery_with_expanded_coding_shreds(num_tx: usize, is_last_in_slot: bool) {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let txs = repeat_with(|| {
|
let txs = repeat_with(|| {
|
||||||
system_transaction::transfer(
|
let from_pubkey = Pubkey::new_unique();
|
||||||
&Keypair::new(), // from
|
let instruction = solana_sdk::system_instruction::transfer(
|
||||||
&Pubkey::new_unique(), // to
|
&from_pubkey,
|
||||||
rng.gen(), // lamports
|
&Pubkey::new_unique(), // to
|
||||||
hash::new_rand(&mut rng), // recent block hash
|
rng.gen(), // lamports
|
||||||
)
|
);
|
||||||
|
let message = solana_sdk::message::Message::new(&[instruction], Some(&from_pubkey));
|
||||||
|
let mut tx = solana_sdk::transaction::Transaction::new_unsigned(message);
|
||||||
|
// Also randomize the signatre bytes.
|
||||||
|
let mut signature = [0u8; 64];
|
||||||
|
rng.fill(&mut signature[..]);
|
||||||
|
tx.signatures = vec![Signature::new(&signature)];
|
||||||
|
tx
|
||||||
})
|
})
|
||||||
.take(num_tx)
|
.take(num_tx)
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -1720,7 +1723,7 @@ pub mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_recovery_with_expanded_coding_shreds() {
|
fn test_recovery_with_expanded_coding_shreds() {
|
||||||
for num_tx in 0..100 {
|
for num_tx in 0..50 {
|
||||||
run_recovery_with_expanded_coding_shreds(num_tx, false);
|
run_recovery_with_expanded_coding_shreds(num_tx, false);
|
||||||
run_recovery_with_expanded_coding_shreds(num_tx, true);
|
run_recovery_with_expanded_coding_shreds(num_tx, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue