Skip to content

test_clz_initcode_context()

Documentation for tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py::test_clz_initcode_context@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py::test_clz_initcode_context --fork Amsterdam

Test CLZ opcode behavior when creating a contract.

Source code in tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
@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 generates 1 parametrized test case across 2 forks.