Skip to content

test_authorization_to_precompile_address()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_authorization_to_precompile_address@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_authorization_to_precompile_address --fork Amsterdam

Test an authorization targeting a precompile address applies.

Authorizing delegation to a precompile address (ecrecover at 0x01) is processed like any other target: the authority's code is set to the precompile's delegation designator. Only the post-state is asserted here; the recipient path becomes a delegation and its exact charge is not the focus of this test.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
@pytest.mark.valid_from("EIP8037")
def test_authorization_to_precompile_address(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test an authorization targeting a precompile address applies.

    Authorizing delegation to a precompile address (ecrecover at 0x01) is
    processed like any other target: the authority's code is set to the
    precompile's delegation designator. Only the post-state is asserted
    here; the recipient path becomes a delegation and its exact charge is
    not the focus of this test.
    """
    precompile_address = Address(0x01)
    recipient = pre.deploy_contract(code=Op.STOP)

    signer = pre.fund_eoa()
    authorization_list = [
        AuthorizationTuple(
            address=precompile_address,
            nonce=0,
            signer=signer,
            creates_account=False,
            writes_delegation=True,
        ),
    ]

    tx = Transaction(
        to=recipient,
        authorization_list=authorization_list,
        sender=pre.fund_eoa(),
    )

    post = {
        signer: Account(
            code=Spec7702.delegation_designation(precompile_address),
        ),
    }
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.