Skip to content

test_eip2930_tx_validity()

Documentation for tests/berlin/eip2930_access_list/test_tx_type.py::test_eip2930_tx_validity@9c2813ee.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/berlin/eip2930_access_list/test_tx_type.py::test_eip2930_tx_validity --fork Amsterdam

Tests that an EIP-2930 tx is correctly rejected before fork activation.

Source code in tests/berlin/eip2930_access_list/test_tx_type.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
@pytest.mark.ported_from(
    [
        "https://github.com/ethereum/legacytests/blob/master/src/LegacyTests/Cancun/GeneralStateTestsFiller/stExample/accessListExampleFiller.yml"
    ],
    pr=["https://github.com/ethereum/execution-specs/pull/1754"],
)
@pytest.mark.parametrize_by_fork("valid", tx_validity)
def test_eip2930_tx_validity(
    state_test: StateTestFiller,
    fork: Fork,
    pre: Alloc,
    valid: bool,
) -> None:
    """
    Tests that an EIP-2930 tx is correctly rejected before fork activation.
    """
    account = pre.deploy_contract(
        code=Op.SSTORE(0, 1),
        storage={0: 0xDEADBEEF},
    )
    sender = pre.fund_eoa()

    tx = Transaction(
        to=account,
        sender=sender,
        gas_limit=100_000,
        access_list=[],
        protected=fork.supports_protected_txs(),
        error=TransactionException.TYPE_1_TX_PRE_FORK if not valid else None,
    )

    post = {account: Account(storage={0: 0xDEADBEEF if not valid else 1})}
    if not valid:
        post[sender] = pre[sender]  # type: ignore

    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 14 forks.