Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Apr 16, 2022
1 parent 772705f commit 59c9326
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
20 changes: 13 additions & 7 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6002,13 +6002,19 @@ pub mod tests {
assert_eq!(tower.last_voted_slot().unwrap(), 1);

// Create a bank where the last vote transaction will have expired
let expired_bank = Arc::new(Bank::new_from_parent(
&bank2,
&Pubkey::default(),
bank2.slot() + MAX_PROCESSING_AGE as Slot,
));
expired_bank.fill_bank_with_ticks();
expired_bank.freeze();
let expired_bank = {
let mut parent_bank = bank2.clone();
for _ in 0..MAX_PROCESSING_AGE {
parent_bank = Arc::new(Bank::new_from_parent(
&parent_bank,
&Pubkey::default(),
parent_bank.slot() + 1,
));
parent_bank.fill_bank_with_ticks();
parent_bank.freeze();
}
parent_bank
};

// Now trying to refresh the vote for slot 1 will succeed because the recent blockhash
// of the last vote transaction has expired
Expand Down
7 changes: 4 additions & 3 deletions poh/src/poh_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,12 +1962,13 @@ mod tests {
);
//create a new bank
let bank = Arc::new(Bank::new_from_parent(&bank, &Pubkey::default(), 2));
//put 2 slots worth of virtual ticks into poh
for _ in 0..(bank.ticks_per_slot() * 2) {
// add virtual ticks into poh for slots 0, 1, and 2
for _ in 0..(bank.ticks_per_slot() * 3) {
poh_recorder.tick();
}
poh_recorder.set_bank(&bank);
assert_eq!(Some(false), bank.check_hash_age(&genesis_hash, 1));
assert_eq!(Some(false), bank.check_hash_age(&genesis_hash, 0));
assert_eq!(Some(true), bank.check_hash_age(&genesis_hash, 1));
}
}

Expand Down
13 changes: 3 additions & 10 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6483,16 +6483,9 @@ impl Bank {
}

pub fn fill_bank_with_ticks(&self) {
let parent_distance = if self.slot() == 0 {
1
} else {
self.slot() - self.parent_slot()
};
for _ in 0..parent_distance {
let last_blockhash = self.last_blockhash();
while self.last_blockhash() == last_blockhash {
self.register_tick(&Hash::new_unique())
}
let last_blockhash = self.last_blockhash();
while self.last_blockhash() == last_blockhash {
self.register_tick(&Hash::new_unique())
}
}

Expand Down

0 comments on commit 59c9326

Please sign in to comment.