Skip to content

Commit 769ea3d

Browse files
committed
EIP-XXXX add simple happy case tests
1 parent e73b5d8 commit 769ea3d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from eth2spec.test.context import spec_state_test, with_electra_and_later
2+
from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with
3+
from eth2spec.test.helpers.state import next_epoch
4+
5+
@with_electra_and_later
6+
@spec_state_test
7+
def test_next_epoch_proposer_lookahead_shifted_to_front(spec, state):
8+
"""Test that the next epoch proposer lookahead is "shifted" to the front at epoch transition."""
9+
# Transition few epochs to pass the MIN_SEED_LOOKAHEAD
10+
next_epoch(spec, state)
11+
next_epoch(spec, state)
12+
# Get initial lookahead
13+
initial_lookahead = state.proposer_lookahead.copy()
14+
15+
# Run epoch processing
16+
yield from run_epoch_processing_with(spec, state, 'process_proposer_lookahead')
17+
18+
# Verify lookahead was shifted correctly
19+
assert state.proposer_lookahead[:spec.SLOTS_PER_EPOCH] == initial_lookahead[spec.SLOTS_PER_EPOCH:]
20+
21+
22+
@with_electra_and_later
23+
@spec_state_test
24+
def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state):
25+
"""Test that the proposer lookahead in the state matches the lookahead computed on the fly."""
26+
# Transition few epochs to pass the MIN_SEED_LOOKAHEAD
27+
next_epoch(spec, state)
28+
next_epoch(spec, state)
29+
30+
# Run epoch processing
31+
yield from run_epoch_processing_with(spec, state, 'process_proposer_lookahead')
32+
33+
# Verify lookahead in state matches the lookahead computed on the fly
34+
computed_lookahead = spec.compute_proposer_lookahead(state)
35+
assert state.proposer_lookahead == computed_lookahead

0 commit comments

Comments
 (0)