Skip to content

test_existing_authority_refund()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_eip_mainnet.py::test_existing_authority_refund@2867859a.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_eip_mainnet.py::test_existing_authority_refund --fork Amsterdam

Re-authorizing an already-delegated authority applies the existing-authority refund and re-points the delegation; the tx succeeds with the new designation installed.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_eip_mainnet.py
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
def test_existing_authority_refund(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Re-authorizing an already-delegated authority applies the
    existing-authority refund and re-points the delegation; the tx
    succeeds with the new designation installed.
    """
    old_target = pre.deploy_contract(code=Op.STOP)
    new_target = pre.deploy_contract(code=Op.STOP)

    # Authority already carries a delegation, so the new authorization
    # triggers REFUND_AUTH_PER_EXISTING_ACCOUNT.
    auth_signer = pre.fund_eoa(delegation=old_target)

    authorization_list = [
        AuthorizationTuple(
            address=new_target,
            nonce=1,
            signer=auth_signer,
        ),
    ]

    tx = Transaction(
        to=auth_signer,
        gas_limit=1_000_000,
        authorization_list=authorization_list,
        sender=pre.fund_eoa(),
    )

    post = {
        auth_signer: Account(
            nonce=2,
            code=Spec7702.delegation_designation(new_target),
        ),
    }
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.