Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Sep 17, 2020
1 parent 805cfde commit 3957b03
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions consensus/fork_choice/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,26 @@ impl ForkChoiceTest {

self
}

/// Check to ensure that we can read the finalized block. This is a regression test.
pub fn check_finalized_block_is_accessible(self) -> Self {
self.harness
.chain
.fork_choice
.write()
.get_block(
&self
.harness
.chain
.head_info()
.unwrap()
.finalized_checkpoint
.root,
)
.unwrap();

self
}
}

fn is_safe_to_update(slot: Slot) -> bool {
Expand Down Expand Up @@ -879,3 +899,11 @@ fn valid_attestation_skip_across_epoch() {
|result| result.unwrap(),
);
}

#[test]
fn can_read_finalized_block() {
ForkChoiceTest::new()
.apply_blocks_while(|_, state| state.finalized_checkpoint.epoch == 0)
.apply_blocks(1)
.check_finalized_block_is_accessible();
}

0 comments on commit 3957b03

Please sign in to comment.