Skip to content

test_clz_gas_cost()

Documentation for tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py::test_clz_gas_cost@2867859a.

Generate fixtures for these test cases for Amsterdam with:

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

Test CLZ opcode gas cost.

Source code in tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@pytest.mark.valid_from("Osaka")
def test_clz_gas_cost(
    state_test: StateTestFiller, pre: Alloc, fork: Fork
) -> None:
    """Test CLZ opcode gas cost."""
    contract_address = pre.deploy_contract(
        CodeGasMeasure(
            code=Op.CLZ(Op.PUSH1(1)),
            extra_stack_items=1,
            overhead_cost=Op.PUSH1.gas_cost(fork),
        ),
        storage={"0x00": "0xdeadbeef"},
    )
    sender = pre.fund_eoa()
    tx = Transaction(to=contract_address, sender=sender)
    post = {
        contract_address: Account(  # Cost measured is CLZ + PUSH1
            storage={"0x00": Op.CLZ.gas_cost(fork)}
        ),
    }
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 2 forks.