Skip to content

test_clz_gas_cost()

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

Test CLZ opcode gas cost.

Source code in tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@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(
        Op.SSTORE(
            0,
            CodeGasMeasure(
                code=Op.CLZ(Op.PUSH1(1)),
                extra_stack_items=1,
                overhead_cost=fork.gas_costs().G_VERY_LOW,
            ),
        ),
        storage={"0x00": "0xdeadbeef"},
    )
    sender = pre.fund_eoa()
    tx = Transaction(to=contract_address, sender=sender, gas_limit=200_000)
    post = {
        contract_address: Account(  # Cost measured is CLZ + PUSH1
            storage={"0x00": fork.gas_costs().G_LOW}
        ),
    }
    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