Add assertion when filling blocktree slot with ticks (#6664)

automerge
This commit is contained in:
Justin Starry 2019-10-31 17:15:07 -04:00 committed by Grimes
parent c52830980a
commit a4d48df30a
1 changed files with 4 additions and 1 deletions

View File

@ -486,6 +486,7 @@ fn process_pending_slots(
Ok(fork_info)
}
// used for tests only
pub fn fill_blocktree_slot_with_ticks(
blocktree: &Blocktree,
ticks_per_slot: u64,
@ -493,7 +494,9 @@ pub fn fill_blocktree_slot_with_ticks(
parent_slot: u64,
last_entry_hash: Hash,
) -> Hash {
let num_slots = (slot - parent_slot).max(1); // Note: slot 0 has parent slot 0
// Only slot 0 can be equal to the parent_slot
assert!(slot.saturating_sub(1) >= parent_slot);
let num_slots = (slot - parent_slot).max(1);
let entries = create_ticks(num_slots * ticks_per_slot, 0, last_entry_hash);
let last_entry_hash = entries.last().unwrap().hash;