Skip to content

test_gas()

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

Generate fixtures for these test cases for Amsterdam with:

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

Test that EXP gas works as expected.

Source code in tests/frontier/opcodes/test_exp.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
@pytest.mark.valid_from("Berlin")
@pytest.mark.parametrize(
    "a", [0, 1, pytest.param(2**256 - 1, id="a2to256minus1")]
)
@pytest.mark.parametrize(
    "exponent",
    [
        0,
        1,
        2,
        1023,
        1024,
        pytest.param(2**255, id="exponent2to255"),
        pytest.param(2**256 - 1, id="exponent2to256minus1"),
    ],
)
def test_gas(
    state_test: StateTestFiller,
    pre: Alloc,
    a: int,
    exponent: int,
    fork: Fork,
) -> None:
    """Test that EXP gas works as expected."""
    gas_test(
        fork=fork,
        state_test=state_test,
        pre=pre,
        setup_code=Op.PUSH32(exponent) + Op.PUSH32(a),
        subject_code=Op.EXP(exponent=exponent),
    )

Parametrized Test Cases

This test generates 21 parametrized test cases across 8 forks.