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@21fb11c8.

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
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
@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