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@44293f1e.

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
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
@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,
):
    """
    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={k: 0 for k in storage}),
            sender: Account(
                nonce=0,
                code="",
                storage={},
            ),
        },
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated) tx_value
...fork_Cancun-state_test-tx_value_0 0
...fork_Cancun-state_test-tx_value_1 1
...fork_CancunToPragueAtTime15k-blockchain_test_from_state_test-tx_value_0 0
...fork_CancunToPragueAtTime15k-blockchain_test_from_state_test-tx_value_1 1