Skip to content

test_eip_7997()

Documentation for tests/amsterdam/eip7997_deterministic_factory_predeploy/test_eip_mainnet.py::test_eip_7997@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7997_deterministic_factory_predeploy/test_eip_mainnet.py::test_eip_7997 --fork Amsterdam

The factory bytecode is present at the canonical Arachnid factory address with nonce 1. Verifies EVM-observable views of the predeploy via EXTCODESIZE, EXTCODEHASH and EXTCODECOPY.

Source code in tests/amsterdam/eip7997_deterministic_factory_predeploy/test_eip_mainnet.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def test_eip_7997(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    The factory bytecode is present at the canonical Arachnid factory
    address with nonce 1. Verifies EVM-observable views of
    the predeploy via `EXTCODESIZE`, `EXTCODEHASH` and `EXTCODECOPY`.
    """
    storage = Storage()
    extcodesize_slot = storage.store_next(
        len(Spec.FACTORY_BYTECODE), "extcodesize"
    )
    extcodehash_slot = storage.store_next(
        Spec.FACTORY_BYTECODE.keccak256(), "extcodehash"
    )
    extcodecopy_hash_slot = storage.store_next(
        Spec.FACTORY_BYTECODE.keccak256(), "extcodecopy_hash"
    )
    caller = pre.deploy_contract(
        Op.SSTORE(extcodesize_slot, Op.EXTCODESIZE(FACTORY))
        + Op.SSTORE(extcodehash_slot, Op.EXTCODEHASH(FACTORY))
        + Op.EXTCODECOPY(FACTORY, 0, 0, Op.EXTCODESIZE(FACTORY))
        + Op.SSTORE(extcodecopy_hash_slot, Op.SHA3(0, Op.EXTCODESIZE(FACTORY)))
        + Op.STOP,
    )
    state_test(
        pre=pre,
        tx=Transaction(
            sender=pre.fund_eoa(),
            to=caller,
        ),
        post={
            FACTORY: Account(code=Spec.FACTORY_BYTECODE),
            caller: Account(storage=storage),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.