Skip to content

test_tx_gas_limit_cap_subcall_context()

Documentation for tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py::test_tx_gas_limit_cap_subcall_context@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py::test_tx_gas_limit_cap_subcall_context --fork Amsterdam

Test the transaction gas limit cap behavior for subcall context.

Source code in tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
@pytest.mark.parametrize(
    "opcode",
    [
        pytest.param(Op.CALL),
        pytest.param(Op.DELEGATECALL),
        pytest.param(Op.CALLCODE),
        pytest.param(Op.STATICCALL),
    ],
)
@pytest.mark.valid_from("Osaka")
def test_tx_gas_limit_cap_subcall_context(
    state_test: StateTestFiller,
    pre: Alloc,
    opcode: Op,
    fork: Fork,
    env: Environment,
) -> None:
    """Test the transaction gas limit cap behavior for subcall context."""
    tx_gas_limit_cap = fork.transaction_gas_limit_cap()
    assert tx_gas_limit_cap is not None, (
        "Fork does not have a transaction gas limit cap"
    )

    caller_address = pre.deploy_contract(
        code=Op.SSTORE(
            0,
            opcode(
                gas=tx_gas_limit_cap + 1,
                address=pre.deploy_contract(
                    code=Op.MSTORE(0, Op.GAS) + Op.RETURN(0, 0x20)
                ),
                ret_offset=0,
                ret_size=0,
            ),
        )
    )

    # Passing tx limit cap as the gas parameter to *CALL operations
    # All tests should pass and the *CALL operations should succeed
    # Gas forwarded = min(remaining gas, specified gas parameter)

    tx = Transaction(
        to=caller_address,
        sender=pre.fund_eoa(),
        gas_limit=tx_gas_limit_cap,
    )

    post = {
        caller_address: Account(storage={"0x00": 1}),
    }

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

Parametrized Test Cases

This test generates 4 parametrized test cases across 2 forks.