diff --git a/src/ethereum_test_specs/blockchain.py b/src/ethereum_test_specs/blockchain.py index 089bdee533..d785440e8f 100644 --- a/src/ethereum_test_specs/blockchain.py +++ b/src/ethereum_test_specs/blockchain.py @@ -45,7 +45,7 @@ from .base import BaseTest, verify_result from .debugging import print_traces -from .helpers import verify_transactions +from .helpers import is_slow_test, verify_transactions def environment_from_parent_header(parent: "FixtureHeader") -> "Environment": @@ -384,6 +384,7 @@ def generate_block_data( previous_env: Environment, previous_alloc: Alloc, eips: Optional[List[int]] = None, + slow: bool = False, ) -> Tuple[FixtureHeader, List[Transaction], List[Bytes] | None, Alloc, Environment]: """ Generate common block data for both make_fixture and make_hive_fixture. @@ -420,6 +421,7 @@ def generate_block_data( reward=fork.get_reward(env.number, env.timestamp), eips=eips, debug_output_path=self.get_next_transition_tool_output_path(), + slow_request=slow, ) try: @@ -528,6 +530,7 @@ def make_fixture( t8n: TransitionTool, fork: Fork, eips: Optional[List[int]] = None, + slow: bool = False, ) -> Fixture: """ Create a fixture from the blockchain test definition. @@ -552,6 +555,7 @@ def make_fixture( previous_env=env, previous_alloc=alloc, eips=eips, + slow=slow, ) fixture_block = FixtureBlockBase( header=header, @@ -610,6 +614,7 @@ def make_hive_fixture( t8n: TransitionTool, fork: Fork, eips: Optional[List[int]] = None, + slow: bool = False, ) -> EngineFixture: """ Create a hive fixture from the blocktest definition. @@ -623,7 +628,13 @@ def make_hive_fixture( for block in self.blocks: header, txs, requests, new_alloc, new_env = self.generate_block_data( - t8n=t8n, fork=fork, block=block, previous_env=env, previous_alloc=alloc, eips=eips + t8n=t8n, + fork=fork, + block=block, + previous_env=env, + previous_alloc=alloc, + eips=eips, + slow=slow, ) if block.rlp is None: fixture_payloads.append( @@ -701,9 +712,9 @@ def generate( """ t8n.reset_traces() if fixture_format == BlockchainEngineFixture: - return self.make_hive_fixture(t8n, fork, eips) + return self.make_hive_fixture(t8n, fork, eips, slow=is_slow_test(request)) elif fixture_format == BlockchainFixture: - return self.make_fixture(t8n, fork, eips) + return self.make_fixture(t8n, fork, eips, slow=is_slow_test(request)) raise Exception(f"Unknown fixture format: {fixture_format}") diff --git a/src/ethereum_test_specs/helpers.py b/src/ethereum_test_specs/helpers.py index 83195efcfa..5446d076ca 100644 --- a/src/ethereum_test_specs/helpers.py +++ b/src/ethereum_test_specs/helpers.py @@ -1,10 +1,11 @@ """ Helper functions """ - from dataclasses import dataclass from typing import Dict, List +import pytest + from ethereum_clis import Result from ethereum_test_exceptions import ExceptionBase, ExceptionMapper, UndefinedException from ethereum_test_types import Transaction @@ -150,3 +151,12 @@ def verify_transactions( verify_transaction_exception(exception_mapper=exception_mapper, info=info) return list(rejected_txs.keys()) + + +def is_slow_test(request: pytest.FixtureRequest) -> bool: + """ + Check if the test is slow + """ + if hasattr(request, "node"): + return request.node.get_closest_marker("slow") is not None + return False diff --git a/src/ethereum_test_specs/state.py b/src/ethereum_test_specs/state.py index 4595d2f6bb..029a2cbc6e 100644 --- a/src/ethereum_test_specs/state.py +++ b/src/ethereum_test_specs/state.py @@ -30,7 +30,7 @@ from .base import BaseTest from .blockchain import Block, BlockchainTest, Header from .debugging import print_traces -from .helpers import verify_transactions +from .helpers import is_slow_test, verify_transactions TARGET_BLOB_GAS_PER_BLOCK = 393216 @@ -124,6 +124,7 @@ def make_state_test_fixture( t8n: TransitionTool, fork: Fork, eips: Optional[List[int]] = None, + slow: bool = False, ) -> Fixture: """ Create a fixture from the state test definition. @@ -151,6 +152,7 @@ def make_state_test_fixture( eips=eips, debug_output_path=self.get_next_transition_tool_output_path(), state_test=True, + slow_request=slow, ) try: @@ -199,7 +201,7 @@ def generate( request=request, t8n=t8n, fork=fork, fixture_format=fixture_format, eips=eips ) elif fixture_format == StateFixture: - return self.make_state_test_fixture(t8n, fork, eips) + return self.make_state_test_fixture(t8n, fork, eips, slow=is_slow_test(request)) raise Exception(f"Unknown fixture format: {fixture_format}")