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
34 changes: 32 additions & 2 deletions tests/prague/eip7685_general_purpose_el_requests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
import pytest

from ethereum_test_forks import Fork
from ethereum_test_tools import Alloc, Block, BlockException, Bytes, Header, Requests
from ethereum_test_tools import (
Alloc,
Block,
BlockException,
Bytes,
EngineAPIError,
Header,
Requests,
)

from ..eip6110_deposits.helpers import DepositInteractionBase, DepositRequest
from ..eip7002_el_triggerable_withdrawals.helpers import (
Expand Down Expand Up @@ -50,6 +58,26 @@ def exception() -> BlockException | None:
return None


@pytest.fixture
def engine_api_error_code(
block_body_override_requests: List[Bytes | SupportsBytes] | None,
) -> EngineAPIError | None:
"""Engine API error code if any."""
if block_body_override_requests is None:
return None
block_body_override_requests_bytes = [bytes(r) for r in block_body_override_requests]
if any(len(r) <= 1 for r in block_body_override_requests_bytes):
return EngineAPIError.InvalidParams

def is_monotonically_increasing(requests: List[bytes]) -> bool:
return all(x[0] < y[0] for x, y in zip(requests, requests[1:], strict=False))

if not is_monotonically_increasing(block_body_override_requests_bytes):
return EngineAPIError.InvalidParams

return None


@pytest.fixture
def blocks(
fork: Fork,
Expand All @@ -59,10 +87,11 @@ def blocks(
| WithdrawalRequestInteractionBase
| ConsolidationRequestInteractionBase
],
block_body_override_requests: (List[Bytes | SupportsBytes] | None),
block_body_override_requests: List[Bytes | SupportsBytes] | None,
block_body_extra_requests: List[SupportsBytes],
correct_requests_hash_in_header: bool,
exception: BlockException | None,
engine_api_error_code: EngineAPIError | None,
) -> List[Block]:
"""List of blocks that comprise the test."""
valid_requests_list: List[DepositRequest | WithdrawalRequest | ConsolidationRequest] = []
Expand Down Expand Up @@ -95,5 +124,6 @@ def blocks(
requests=block_body_override_requests,
exception=exception,
rlp_modifier=rlp_modifier,
engine_api_error_code=engine_api_error_code,
)
]
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ def invalid_requests_block_combinations(fork: Fork) -> List[Any]:
In the event of a new request type, the `all_request_types` dictionary should be updated
with the new request type and its corresponding request-generating transaction.
Returned parameters are: requests, block_body_override_requests, exception
"""
assert fork.max_request_type() == 2, "Test update is needed for new request types"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@

@pytest.fixture
def block_body_extra_requests(fork: Fork, invalid_request_data: bytes) -> List[bytes]:
"""List of requests that overwrite the requests in the header. None by default."""
"""
Create a request with an invalid type for the fork.
This overrides the default fixture and its behavior defined in conftest.py.
"""
invalid_request_type = fork.max_request_type() + 1
return [bytes([invalid_request_type]) + invalid_request_data]

Expand Down
Loading