Skip to content

Commit 8b4ebbe

Browse files
authored
BlockSpec check_state_transition (#1186)
1 parent 74370a2 commit 8b4ebbe

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

packages/testing/src/consensus_testing/test_fixtures/state_transition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def generate(self) -> StateTransitionFixture:
116116

117117
if cached_state is not None:
118118
state = cached_state
119-
elif block_spec.skip_slot_processing:
119+
elif block_spec.skip_slot_processing and not block_spec.check_state_transition:
120120
state = spec.process_block(state, block)
121121
else:
122122
state = spec.state_transition(state, block=block)

packages/testing/src/consensus_testing/test_types/block_spec.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class BlockSpec(CamelModel):
7171
skip_slot_processing: bool = False
7272
"""Skip automatic slot advancement before processing, to exercise slot-mismatch failures."""
7373

74+
check_state_transition: bool = False
75+
"""Call `state_transition` after block is generated by `_build_block_from_spec`."""
76+
7477
def resolve_proposer_index(self, num_validators: int) -> ValidatorIndex:
7578
"""Return the proposer index, falling back to the spec's round-robin schedule."""
7679
if self.proposer_index is not None:

tests/consensus/lstar/state_transition/test_slot_monotonicity.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ def test_process_slots_target_equal_to_state_slot_rejected(
3939
state_transition_test(
4040
pre=pre_state,
4141
blocks=[
42-
BlockSpec(slot=Slot(1)),
42+
BlockSpec(
43+
slot=Slot(1),
44+
skip_slot_processing=True,
45+
check_state_transition=True,
46+
),
4347
],
4448
post=None,
4549
expected_rejection=ExpectedRejection(

0 commit comments

Comments
 (0)