Skip to content

test_gas()

Documentation for tests/frontier/opcodes/test_log.py::test_gas@8db70f93.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/frontier/opcodes/test_log.py::test_gas --fork Amsterdam

Test that LOGx gas works as expected.

Source code in tests/frontier/opcodes/test_log.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@pytest.mark.valid_from("Berlin")
@pytest.mark.parametrize(
    "opcode,topics",
    [(Op.LOG0, 0), (Op.LOG1, 1), (Op.LOG2, 2), (Op.LOG3, 3), (Op.LOG4, 4)],
)
@pytest.mark.parametrize(
    "data_size",
    [
        0,
        1,
        2,
        1023,
        1024,
    ],
)
def test_gas(
    state_test: StateTestFiller,
    pre: Alloc,
    opcode: Op,
    topics: int,
    data_size: int,
    fork: Fork,
) -> None:
    """Test that LOGx gas works as expected."""
    gas_test(
        fork=fork,
        state_test=state_test,
        pre=pre,
        setup_code=Op.MSTORE8(data_size, 0)
        + Op.PUSH1(0) * topics
        + Op.PUSH32(data_size)
        + Op.PUSH1(0),
        subject_code=opcode(data_size=data_size),
    )

Parametrized Test Cases

This test generates 25 parametrized test cases across 8 forks.