Skip to content

test_clz_push_operation_same_value()

Documentation for tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py::test_clz_push_operation_same_value@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

Test CLZ opcode returns the same value via different push operations.

Source code in tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
@pytest.mark.valid_from("Osaka")
def test_clz_push_operation_same_value(state_test: StateTestFiller, pre: Alloc) -> None:
    """Test CLZ opcode returns the same value via different push operations."""
    storage = {}

    code = Op.SSTORE(0, Op.CLZ(Op.PUSH0))
    storage[0x00] = 256

    for bit in range(1, 33):  # PUSH value
        for push_n in range(bit, 33):  # PUSHn opcode
            op = getattr(Op, f"PUSH{push_n}")
            key = 100 * bit + push_n
            code += Op.SSTORE(key, Op.CLZ(op[1 << bit]))
            storage[key] = 255 - bit

    code_address = pre.deploy_contract(code=code)

    tx = Transaction(
        to=code_address,
        sender=pre.fund_eoa(),
        gas_limit=12_000_000,
    )

    post = {
        code_address: Account(
            storage=storage,
        )
    }

    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