Skip to content

test_create_tx_balance_only_target()

Documentation for tests/frontier/create/test_create_collision.py::test_create_tx_balance_only_target@49633827.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/frontier/create/test_create_collision.py::test_create_tx_balance_only_target --fork Amsterdam

Test that a contract creation transaction succeeds when the target address has only a balance: an account with zero nonce, no code and no storage is not a collision (EIP-684).

Source code in tests/frontier/create/test_create_collision.py
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
@pytest.mark.with_all_contract_creating_tx_types
def test_create_tx_balance_only_target(
    state_test: StateTestFiller,
    pre: Alloc,
    tx_type: int,
) -> None:
    """
    Test that a contract creation transaction succeeds when the target
    address has only a balance: an account with zero nonce, no code and
    no storage is not a collision (EIP-684).
    """
    tx = Transaction(
        sender=pre.fund_eoa(),
        ty=tx_type,
        to=None,
        data=CORRECT_INITCODE,
        protected=False,
    )

    created_contract_address = tx.created_contract

    pre[created_contract_address] = Account(balance=1)

    state_test(
        pre=pre,
        post={
            created_contract_address: Account(
                balance=1,
                code=CORRECT_INITCODE.deploy_code,
                storage={0x00: 0x01},
            ),
        },
        tx=tx,
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 16 forks.