Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -61,8 +61,11 @@ class StateTransitionTest(BaseConsensusFixture):
"""
The filled Blocks, processed through the specs.

This is a private attribute not part of the model schema. Tests cannot set
this. The framework populates it during make_fixture().
This is a private attribute not part of the model schema.

Tests cannot set this.

The framework populates it during make_fixture().
"""

post: StateExpectation | None = None
Expand Down Expand Up @@ -215,11 +218,11 @@ def _build_block_from_spec(self, spec: BlockSpec, state: State) -> tuple[Block,
if not spec.skip_slot_processing:
temp_state = state.process_slots(spec.slot)

# Use provided parent_root or compute it
# Use provided parent root or compute it
if spec.parent_root is not None:
parent_root = spec.parent_root
else:
source_state = temp_state if temp_state is not None else state
source_state = temp_state or state
parent_root = hash_tree_root(source_state.latest_block_header)

# Extract attestations from body if provided
Expand All @@ -238,16 +241,15 @@ def _build_block_from_spec(self, spec: BlockSpec, state: State) -> tuple[Block,
)
return block, None

temp_block = Block(
slot=spec.slot,
proposer_index=proposer_index,
parent_root=parent_root,
state_root=Bytes32.zero(),
body=spec.body or BlockBody(attestations=aggregated_attestations),
)

# For invalid tests, return incomplete block without processing
if self.expect_exception is not None or spec.skip_slot_processing:
return temp_block, None
return Block(
slot=spec.slot,
proposer_index=proposer_index,
parent_root=parent_root,
state_root=Bytes32.zero(),
body=spec.body or BlockBody(attestations=aggregated_attestations),
), None

# Convert aggregated attestations to plain attestations to build block
plain_attestations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class BlockSpec(CamelModel):

skip_slot_processing: bool = False
"""
If True, the state transition fixture skips automatic slot advancement before
processing this block. Useful for tests that intentionally exercise slot
mismatch failures.
If True, the state transition fixture skips automatic slot advancement
before processing this block.

Useful for tests that intentionally exercise slot mismatch failures.
"""
Loading