Skip to content

test_set_code_type_tx_pre_fork()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_set_code_type_tx_pre_fork@892e6d1e.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_set_code_type_tx_pre_fork --fork Prague

Reject blocks with set code type transactions before the Prague fork.

This test was based on: tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_self_sponsored_set_ code

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
@pytest.mark.parametrize(
    "tx_value",
    [0, 1],
)
@pytest.mark.exception_test
@pytest.mark.valid_at_transition_to("Prague")
def test_set_code_type_tx_pre_fork(
    state_test: StateTestFiller,
    pre: Alloc,
    tx_value: int,
) -> None:
    """
    Reject blocks with set code type transactions before the Prague fork.

    This test was based on:
    tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_self_sponsored_set_
    code
    """
    storage = Storage()
    sender = pre.fund_eoa()

    set_code = (
        Op.SSTORE(storage.store_next(sender), Op.ORIGIN)
        + Op.SSTORE(storage.store_next(sender), Op.CALLER)
        + Op.SSTORE(storage.store_next(tx_value), Op.CALLVALUE)
        + Op.STOP
    )
    set_code_to_address = pre.deploy_contract(
        set_code,
    )

    tx = Transaction(
        gas_limit=10_000_000,
        to=sender,
        value=tx_value,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address,
                nonce=1,
                signer=sender,
            ),
        ],
        sender=sender,
        error=TransactionException.TYPE_4_TX_PRE_FORK,
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            set_code_to_address: Account(storage=dict.fromkeys(storage, 0)),
            sender: Account(
                nonce=0,
                code="",
                storage={},
            ),
        },
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.