Rework test parameters to be shreds instead of entries (#21780)

The number of shreds that result from a given number of entries is
variable and in our test case, somewhat unintuitive to think about when
trying to determine how much data we're pushing into the blockstore. So,
this change converts the unit of test parameters from entries to shreds.

This change also cleans up some variable naming for clarity and prints.
This commit is contained in:
steviez
2021-12-13 23:34:43 -06:00
committed by GitHub
parent 018b54dbd7
commit 4a9d7318d1
2 changed files with 60 additions and 43 deletions

View File

@ -12,7 +12,10 @@ use {
blockstore_meta::*,
leader_schedule_cache::LeaderScheduleCache,
next_slots_iterator::NextSlotsIterator,
shred::{Result as ShredResult, Shred, ShredType, Shredder, SHRED_PAYLOAD_SIZE},
shred::{
max_ticks_per_n_shreds, Result as ShredResult, Shred, ShredType, Shredder,
SHRED_PAYLOAD_SIZE,
},
},
bincode::deserialize,
log::*,
@ -3824,6 +3827,18 @@ pub fn make_many_slot_entries(
(shreds, entries)
}
// used for tests only
// Create `num_shreds` shreds for [start_slot, start_slot + num_slot) slots
pub fn make_many_slot_shreds(
start_slot: u64,
num_slots: u64,
num_shreds_per_slot: u64,
) -> (Vec<Shred>, Vec<Entry>) {
// Use `None` as shred_size so the default (full) value is used
let num_entries = max_ticks_per_n_shreds(num_shreds_per_slot, None);
make_many_slot_entries(start_slot, num_slots, num_entries)
}
// Create shreds for slots that have a parent-child relationship defined by the input `chain`
// used for tests only
pub fn make_chaining_slot_entries(