Skip to content

test_factory_direct_eoa_call()

Documentation for tests/amsterdam/eip7997_deterministic_factory_predeploy/test_factory.py::test_factory_direct_eoa_call@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7997_deterministic_factory_predeploy/test_factory.py::test_factory_direct_eoa_call --fork Amsterdam

A transaction sent directly to the factory address (no relay contract) deploys at the expected CREATE2 address.

Source code in tests/amsterdam/eip7997_deterministic_factory_predeploy/test_factory.py
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
def test_factory_direct_eoa_call(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    A transaction sent directly to the factory address (no relay contract)
    deploys at the expected `CREATE2` address.
    """
    salt = 0xCAFE
    runtime_code = Op.PUSH1(0x01) + Op.PUSH1(0x00) + Op.RETURN
    initcode = Initcode(deploy_code=runtime_code)
    expected_address = compute_create2_address(FACTORY, salt, initcode)

    state_test(
        pre=pre,
        tx=Transaction(
            sender=pre.fund_eoa(),
            to=FACTORY,
            data=Hash(salt) + bytes(initcode),
        ),
        post={
            expected_address: Account(nonce=1, code=bytes(runtime_code)),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.