Skip to content

test_extcodehash_precompile()

Documentation for tests/constantinople/eip1052_extcodehash/test_extcodehash.py::test_extcodehash_precompile@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/constantinople/eip1052_extcodehash/test_extcodehash.py::test_extcodehash_precompile --fork Amsterdam

Test EXTCODEHASH/EXTCODESIZE of precompile addresses.

Precompiles have no associated code, so both return 0.

Source code in tests/constantinople/eip1052_extcodehash/test_extcodehash.py
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
@pytest.mark.ported_from(
    [
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stExtCodeHash/extCodeHashPrecompilesFiller.yml",  # noqa: E501
    ],
    pr=["https://github.com/ethereum/execution-specs/pull/2302"],
)
@pytest.mark.with_all_precompiles
def test_extcodehash_precompile(
    state_test: StateTestFiller,
    pre: Alloc,
    precompile: Address,
) -> None:
    """
    Test EXTCODEHASH/EXTCODESIZE of precompile addresses.

    Precompiles have no associated code, so both return 0.
    """
    storage = Storage()

    code = Op.SSTORE(
        storage.store_next(0),
        Op.EXTCODEHASH(precompile),
    ) + Op.SSTORE(
        storage.store_next(0),
        Op.EXTCODESIZE(precompile),
    )

    code_address = pre.deploy_contract(code, storage=storage.canary())

    tx = Transaction(sender=pre.fund_eoa(), to=code_address)

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

Parametrized Test Cases

This test generates 18 parametrized test cases across 10 forks.