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@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

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
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
@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 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