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

Generate fixtures for these test cases for Bogota with:

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

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
@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 4 forks.