Skip to content

test_clz_stack_underflow()

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

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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
@EIPChecklist.Opcode.Test.StackUnderflow()
@EIPChecklist.Opcode.Test.StackComplexOperations.StackHeights.Zero()
@pytest.mark.valid_from("Osaka")
def test_clz_stack_underflow(state_test: StateTestFiller, pre: Alloc) -> None:
    """
    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