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@e9958ed2.

Generate fixtures for these test cases for Osaka with:

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

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
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
@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

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

Test ID (Abbreviated) opcode
...fork_Osaka-state_test-opcode_CALL CALL
...fork_Osaka-state_test-opcode_DELEGATECALL DELEGATECALL
...fork_Osaka-state_test-opcode_CALLCODE CALLCODE
...fork_Osaka-state_test-opcode_STATICCALL STATICCALL
...fork_Osaka-blockchain_test_from_state_test-opcode_CALL CALL
...fork_Osaka-blockchain_test_from_state_test-opcode_DELEGATECALL DELEGATECALL
...fork_Osaka-blockchain_test_from_state_test-opcode_CALLCODE CALLCODE
...fork_Osaka-blockchain_test_from_state_test-opcode_STATICCALL STATICCALL