Skip to content

test_clz_stack_underflow()

Documentation for tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py::test_clz_stack_underflow@0f7c73a7.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py::test_clz_stack_underflow --fork Osaka

Test CLZ opcode with empty stack (should revert due to stack underflow).

Source code in tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
@pytest.mark.valid_from("Osaka")
def test_clz_stack_underflow(state_test: StateTestFiller, pre: Alloc):
    """Test CLZ opcode with empty stack (should revert due to stack underflow)."""
    sender = pre.fund_eoa()
    callee_address = pre.deploy_contract(
        code=Op.CLZ + Op.STOP,  # No stack items, should underflow
    )
    caller_address = pre.deploy_contract(
        code=Op.SSTORE(0, Op.CALL(gas=0xFFFF, address=callee_address)),
        storage={"0x00": "0xdeadbeef"},
    )
    tx = Transaction(
        to=caller_address,
        sender=sender,
        gas_limit=200_000,
    )
    post = {
        caller_address: Account(
            storage={"0x00": 0}  # Call failed due to stack underflow
        ),
    }
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test