Skip to content

test_delegation_clearing_failing_tx()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_delegation_clearing_failing_tx@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_delegation_clearing_failing_tx --fork Amsterdam

Test clearing the delegation of an account in a transaction that fails, OOGs or reverts.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
@pytest.mark.parametrize(
    "entry_code",
    [
        pytest.param(Om.OOG + Op.STOP, id="out_of_gas"),
        pytest.param(Op.INVALID, id="invalid_opcode"),
        pytest.param(Op.REVERT(0, 0), id="revert"),
    ],
)
def test_delegation_clearing_failing_tx(
    state_test: StateTestFiller,
    pre: Alloc,
    entry_code: Bytecode,
) -> None:
    """
    Test clearing the delegation of an account in a transaction that fails,
    OOGs or reverts.
    """  # noqa: D417
    pre_set_delegation_code = Op.RETURN(0, 1)
    pre_set_delegation_address = pre.deploy_contract(pre_set_delegation_code)

    auth_signer = pre.fund_eoa(0, delegation=pre_set_delegation_address)

    entry_address = pre.deploy_contract(entry_code)

    authorization = AuthorizationTuple(
        address=Spec.RESET_DELEGATION_ADDRESS,  # Reset
        nonce=auth_signer.nonce,
        signer=auth_signer,
    )

    tx = Transaction(
        gas_limit=100_000,
        to=entry_address,
        value=0,
        authorization_list=[authorization],
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            auth_signer: Account(
                nonce=auth_signer.nonce + 1,
                code=b"",
                storage={},
            ),
        },
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 3 forks.