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@26332146.

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
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
@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(
        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.