Skip to content

test_extcodesize()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_eip_mainnet.py::test_extcodesize@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_extcodesize --fork Amsterdam

EXTCODESIZE pays the EIP-8038 account access plus the code-read surcharge and succeeds, returning the target's non-zero code size.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_eip_mainnet.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
def test_extcodesize(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    ``EXTCODESIZE`` pays the EIP-8038 account access plus the code-read
    surcharge and succeeds, returning the target's non-zero code size.
    """
    target = pre.deploy_contract(code=Op.STOP * 3)

    storage = Storage()
    contract = pre.deploy_contract(
        code=Op.SSTORE(storage.store_next(3), Op.EXTCODESIZE(target)),
    )

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

    post = {contract: Account(storage=storage)}
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.