Skip to content

Commit fb3cd63

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

File tree

1 file changed

+36
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)