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@0f7c73a7.

Generate fixtures for these test cases for Prague with:

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

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
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
@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,
):
    """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

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) entry_code
...fork_Prague-state_test-out_of_gas
...fork_Prague-state_test-invalid_opcode INVALID
...fork_Prague-state_test-revert
...fork_Prague-blockchain_test_from_state_test-out_of_gas
...fork_Prague-blockchain_test_from_state_test-invalid_opcode INVALID
...fork_Prague-blockchain_test_from_state_test-revert
...fork_Osaka-state_test-out_of_gas
...fork_Osaka-state_test-invalid_opcode INVALID
...fork_Osaka-state_test-revert
...fork_Osaka-blockchain_test_from_state_test-out_of_gas
...fork_Osaka-blockchain_test_from_state_test-invalid_opcode INVALID
...fork_Osaka-blockchain_test_from_state_test-revert