Skip to content

test_contract_creating_tx()

Documentation for tests/shanghai/eip3860_initcode/test_initcode.py::test_contract_creating_tx@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/shanghai/eip3860_initcode/test_initcode.py::test_contract_creating_tx --fork Prague

Tests creating a contract using a transaction with an initcode that is on/over the max allowed limit.

Source code in tests/shanghai/eip3860_initcode/test_initcode.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@pytest.mark.parametrize(
    "initcode",
    [
        INITCODE_ZEROS_MAX_LIMIT,
        INITCODE_ONES_MAX_LIMIT,
        INITCODE_ZEROS_OVER_LIMIT,
        INITCODE_ONES_OVER_LIMIT,
    ],
    ids=get_initcode_name,
)
def test_contract_creating_tx(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    post: Alloc,
    sender: EOA,
    initcode: Initcode,
):
    """
    Tests creating a contract using a transaction with an initcode that is
    on/over the max allowed limit.
    """
    create_contract_address = compute_create_address(
        address=sender,
        nonce=0,
    )

    tx = Transaction(
        nonce=0,
        to=None,
        data=initcode,
        gas_limit=10000000,
        gas_price=10,
        sender=sender,
    )

    if len(initcode) > Spec.MAX_INITCODE_SIZE:
        # Initcode is above the max size, tx inclusion in the block makes
        # it invalid.
        post[create_contract_address] = Account.NONEXISTENT
        tx.error = TransactionException.INITCODE_SIZE_EXCEEDED
    else:
        # Initcode is at or below the max size, tx inclusion in the block
        # is ok and the contract is successfully created.
        post[create_contract_address] = Account(code=Op.STOP)

    state_test(
        env=env,
        pre=pre,
        post=post,
        tx=tx,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) initcode
...fork_Shanghai-state_test-max_size_zeros max_size_zeros
...fork_Shanghai-state_test-max_size_ones max_size_ones
...fork_Shanghai-state_test-over_limit_zeros over_limit_zeros
...fork_Shanghai-state_test-over_limit_ones over_limit_ones
...fork_Shanghai-blockchain_test_from_state_test-max_size_zeros max_size_zeros
...fork_Shanghai-blockchain_test_from_state_test-max_size_ones max_size_ones
...fork_Shanghai-blockchain_test_from_state_test-over_limit_zeros over_limit_zeros
...fork_Shanghai-blockchain_test_from_state_test-over_limit_ones over_limit_ones
...fork_Cancun-state_test-max_size_zeros max_size_zeros
...fork_Cancun-state_test-max_size_ones max_size_ones
...fork_Cancun-state_test-over_limit_zeros over_limit_zeros
...fork_Cancun-state_test-over_limit_ones over_limit_ones
...fork_Cancun-blockchain_test_from_state_test-max_size_zeros max_size_zeros
...fork_Cancun-blockchain_test_from_state_test-max_size_ones max_size_ones
...fork_Cancun-blockchain_test_from_state_test-over_limit_zeros over_limit_zeros
...fork_Cancun-blockchain_test_from_state_test-over_limit_ones over_limit_ones
...fork_Prague-state_test-max_size_zeros max_size_zeros
...fork_Prague-state_test-max_size_ones max_size_ones
...fork_Prague-state_test-over_limit_zeros over_limit_zeros
...fork_Prague-state_test-over_limit_ones over_limit_ones
...fork_Prague-blockchain_test_from_state_test-max_size_zeros max_size_zeros
...fork_Prague-blockchain_test_from_state_test-max_size_ones max_size_ones
...fork_Prague-blockchain_test_from_state_test-over_limit_zeros over_limit_zeros
...fork_Prague-blockchain_test_from_state_test-over_limit_ones over_limit_ones
...fork_Osaka-state_test-max_size_zeros max_size_zeros
...fork_Osaka-state_test-max_size_ones max_size_ones
...fork_Osaka-state_test-over_limit_zeros over_limit_zeros
...fork_Osaka-state_test-over_limit_ones over_limit_ones
...fork_Osaka-blockchain_test_from_state_test-max_size_zeros max_size_zeros
...fork_Osaka-blockchain_test_from_state_test-max_size_ones max_size_ones
...fork_Osaka-blockchain_test_from_state_test-over_limit_zeros over_limit_zeros
...fork_Osaka-blockchain_test_from_state_test-over_limit_ones over_limit_ones