Skip to content

test_authorization_gas()

Documentation for tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_eip_mainnet.py::test_authorization_gas@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_eip_mainnet.py::test_authorization_gas --fork Amsterdam

Gas for one EIP-7702 authorization, per authority pre-state.

Source code in tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_eip_mainnet.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.parametrize(
    "action",
    [
        pytest.param(AuthorizationAction.CREATES_ACCOUNT, id="new_authority"),
        pytest.param(
            AuthorizationAction.SETS_NEW_DELEGATION, id="existing_authority"
        ),
    ],
)
def test_authorization_gas(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    action: AuthorizationAction,
) -> None:
    """Gas for one EIP-7702 authorization, per authority pre-state."""
    scenario = build_authorization(pre, action)
    authorization_list = [scenario.authorization]
    gas_used = authorization_transaction_cost(fork, authorization_list)

    tx = Transaction(
        to=pre.deploy_contract(code=Op.STOP),
        authorization_list=authorization_list,
        gas_limit=gas_used,
        sender=pre.fund_eoa(),
        expected_receipt=TransactionReceipt(cumulative_gas_used=gas_used),
    )

    post = {scenario.authority: scenario.applied_account}
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.