mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-09 11:25:55 +00:00
Fix invalid attestation verification condition (#1321)
* Fix bug with attestation target * Change comment wording
This commit is contained in:
@@ -106,6 +106,14 @@ impl ForkChoiceTest {
|
||||
self
|
||||
}
|
||||
|
||||
/// Skips `count` slots, without producing a block.
|
||||
pub fn skip_slots(self, count: usize) -> Self {
|
||||
for _ in 0..count {
|
||||
self.harness.advance_slot();
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Build the chain whilst `predicate` returns `true`.
|
||||
pub fn apply_blocks_while<F>(self, mut predicate: F) -> Self
|
||||
where
|
||||
@@ -810,3 +818,22 @@ fn invalid_attestation_delayed_slot() {
|
||||
.skip_slot()
|
||||
.inspect_queued_attestations(|queue| assert_eq!(queue.len(), 0));
|
||||
}
|
||||
|
||||
/// Tests that the correct target root is used when the attested-to block is in a prior epoch to
|
||||
/// the attestation.
|
||||
#[test]
|
||||
fn valid_attestation_skip_across_epoch() {
|
||||
ForkChoiceTest::new()
|
||||
.apply_blocks(E::slots_per_epoch() as usize - 1)
|
||||
.skip_slots(2)
|
||||
.apply_attestation_to_chain(
|
||||
MutationDelay::NoDelay,
|
||||
|attestation, _chain| {
|
||||
assert_eq!(
|
||||
attestation.data.target.root,
|
||||
attestation.data.beacon_block_root
|
||||
)
|
||||
},
|
||||
|result| result.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user