Skip to content

test_clz_initcode_context()

Documentation for tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py::test_clz_initcode_context@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_initcode_context --fork Osaka

Test CLZ opcode behavior when creating a contract.

Source code in tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
@EIPChecklist.Opcode.Test.ExecutionContext.Initcode.Behavior.Tx()
@pytest.mark.valid_from("Osaka")
def test_clz_initcode_context(state_test: StateTestFiller, pre: Alloc) -> None:
    """Test CLZ opcode behavior when creating a contract."""
    bits = [0, 1, 64, 128, 255]

    storage = Storage()

    init_code = Bytecode()
    for bit in bits:
        init_code += Op.SSTORE(storage.store_next(255 - bit), Op.CLZ(1 << bit))

    sender_address = pre.fund_eoa()

    contract_address = compute_create_address(address=sender_address, nonce=0)

    tx = Transaction(
        to=None,
        gas_limit=6_000_000,
        data=init_code,
        sender=sender_address,
    )

    post = {
        contract_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