Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
from eth2spec.test.context import spec_state_test, with_fulu_and_later
from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with
from eth2spec.test.helpers.state import next_epoch


@with_fulu_and_later
@spec_state_test
def test_next_epoch_proposer_lookahead_shifted_to_front(spec, state):
"""Test that the next epoch proposer lookahead is shifted to the front at epoch transition."""
# Transition few epochs to pass the MIN_SEED_LOOKAHEAD
next_epoch(spec, state)
next_epoch(spec, state)
def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state):
"""Test that the proposer lookahead in the state matches the computed lookahead."""
# Transition few epochs to past the MIN_SEED_LOOKAHEAD
for _ in range(spec.MIN_SEED_LOOKAHEAD + 1):
next_epoch(spec, state)

# Get initial lookahead
initial_lookahead = state.proposer_lookahead.copy()

# Run epoch processing
yield "pre", state
next_epoch(spec, state)
yield "post", state
yield from run_epoch_processing_with(spec, state, "process_proposer_lookahead")

# Verify lookahead was shifted correctly
assert (
state.proposer_lookahead[: spec.SLOTS_PER_EPOCH]
== initial_lookahead[spec.SLOTS_PER_EPOCH :]
)

# run_epoch_processing_with does not increment the slot
state.slot += 1

@with_fulu_and_later
@spec_state_test
def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state):
"""Test that the proposer lookahead in the state matches the lookahead computed on the fly."""
# Transition few epochs to pass the MIN_SEED_LOOKAHEAD
next_epoch(spec, state)
next_epoch(spec, state)

# Run epoch processing
yield "pre", state
next_epoch(spec, state)
yield "post", state

# Verify lookahead in state matches the lookahead computed on the fly
# Verify lookahead in state matches the computed lookahead
computed_lookahead = spec.initialize_proposer_lookahead(state)
assert state.proposer_lookahead == computed_lookahead