Add local cluster test to repro slot hash expiry bug (#21873)
This commit is contained in:
@ -7,9 +7,23 @@ use {
|
||||
std::{iter::FromIterator, ops::Deref},
|
||||
};
|
||||
|
||||
pub use crate::clock::Slot;
|
||||
|
||||
pub const MAX_ENTRIES: usize = 512; // about 2.5 minutes to get your vote in
|
||||
|
||||
pub use crate::clock::Slot;
|
||||
// This is to allow tests with custom slot hash expiry to avoid having to generate
|
||||
// 512 blocks for such tests.
|
||||
static mut NUM_ENTRIES: usize = MAX_ENTRIES;
|
||||
|
||||
pub fn get_entries() -> usize {
|
||||
unsafe { NUM_ENTRIES }
|
||||
}
|
||||
|
||||
pub fn set_entries_for_tests_only(_entries: usize) {
|
||||
unsafe {
|
||||
NUM_ENTRIES = _entries;
|
||||
}
|
||||
}
|
||||
|
||||
pub type SlotHash = (Slot, Hash);
|
||||
|
||||
@ -23,7 +37,7 @@ impl SlotHashes {
|
||||
Ok(index) => (self.0)[index] = (slot, hash),
|
||||
Err(index) => (self.0).insert(index, (slot, hash)),
|
||||
}
|
||||
(self.0).truncate(MAX_ENTRIES);
|
||||
(self.0).truncate(get_entries());
|
||||
}
|
||||
pub fn position(&self, slot: &Slot) -> Option<usize> {
|
||||
self.binary_search_by(|(probe, _)| slot.cmp(probe)).ok()
|
||||
|
Reference in New Issue
Block a user