Skip to content

test_contract_creating_tx()

Documentation for tests/shanghai/eip3860_initcode/test_initcode.py::test_contract_creating_tx@verkle@v0.0.6.

Generate fixtures for these test cases for Shanghai with:

Shanghai only:

fill -v tests/shanghai/eip3860_initcode/test_initcode.py::test_contract_creating_tx --fork=Shanghai --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Shanghai:

fill -v tests/shanghai/eip3860_initcode/test_initcode.py::test_contract_creating_tx --until=Shanghai

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
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
172
173
174
@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.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID initcode
max_size_zeros max_size_zeros
max_size_ones max_size_ones
over_limit_zeros over_limit_zeros
over_limit_ones over_limit_ones
max_size_zeros max_size_zeros
max_size_ones max_size_ones
over_limit_zeros over_limit_zeros
over_limit_ones over_limit_ones