Skip to content

test_init_collision_create_tx()

Documentation for tests/paris/eip7610_create_collision/test_initcollision.py::test_init_collision_create_tx@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/paris/eip7610_create_collision/test_initcollision.py::test_init_collision_create_tx --fork Amsterdam

Test that a contract creation transaction exceptionally aborts when the target address has a non-empty storage, balance, nonce, or code.

Source code in tests/paris/eip7610_create_collision/test_initcollision.py
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@pytest.mark.with_all_contract_creating_tx_types
@pytest.mark.eels_base_coverage
def test_init_collision_create_tx(
    state_test: StateTestFiller,
    pre: Alloc,
    tx_type: int,
    collision_nonce: int,
    collision_balance: int,
    collision_code: bytes,
    initcode: Bytecode,
    fork: Fork,
) -> None:
    """
    Test that a contract creation transaction exceptionally aborts when
    the target address has a non-empty storage, balance, nonce, or code.
    """
    tx = Transaction(
        sender=pre.fund_eoa(),
        ty=tx_type,
        to=None,
        data=initcode,
    )

    created_contract_address = tx.created_contract

    # This is the collision
    pre[created_contract_address] = Account(
        storage={0x01: 0x01},
        nonce=collision_nonce,
        balance=collision_balance,
        code=collision_code,
    )

    expected_block_access_list = None
    if fork.is_eip_enabled(7928):
        expected_block_access_list = BlockAccessListExpectation(
            account_expectations={
                created_contract_address: BalAccountExpectation.empty()
            }
        )

    state_test(
        pre=pre,
        post={
            created_contract_address: Account(
                storage={0x01: 0x01},
            ),
        },
        tx=tx,
        expected_block_access_list=expected_block_access_list,
    )

Parametrized Test Cases

This test generates 9 parametrized test cases across 6 forks.