Skip to content

test_invalid()

Documentation for tests/byzantium/eip196_ec_add_mul/test_ecadd.py::test_invalid@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/byzantium/eip196_ec_add_mul/test_ecadd.py::test_invalid --fork Bogota

Test the invalid inputs to the ECADD precompile.

Source code in tests/byzantium/eip196_ec_add_mul/test_ecadd.py
@pytest.mark.parametrize(
    "input_data, expected_output",
    [
        pytest.param(
            PointG1(1, 1) + Spec.INF_G1,
            b"",
            id="pt_1_1_plus_inf",
        ),
        pytest.param(
            Spec.INF_G1 + PointG1(1, 3),
            b"",
            id="inf_plus_pt_1_3",
        ),
        pytest.param(
            PointG1(0, 3) + Spec.INF_G1,
            b"",
            id="pt_0_3_plus_inf",
        ),
        pytest.param(
            PointG1(1, 3) + b"\0" * 1,
            b"",
            id="pt_1_3_plus_1_zero_byte",
        ),
        pytest.param(
            PointG1(1, 3) + b"\0" * 16,
            b"",
            id="pt_1_3_plus_16_zero_bytes",
        ),
        pytest.param(
            PointG1(1, 3) + b"\0" * 32,
            b"",
            id="pt_1_3_plus_32_zero_bytes",
        ),
        pytest.param(
            PointG1(6, 9) + PointG1(0x126198C, 0x1E4DC),
            b"",
            id="pt_6_9_plus_pt_0x126198c_0x1e4dc",
        ),
        pytest.param(
            PointG1(Spec.G1.x + Spec.P, Spec.G1.y) + Spec.INF_G1,
            b"",
            id="Pplus1_2_plus_inf",
        ),
        pytest.param(
            PointG1(Spec.G1.x, Spec.G1.y + Spec.P) + Spec.INF_G1,
            b"",
            id="1_Pplus2_plus_inf",
        ),
        pytest.param(
            Spec.INF_G1 + PointG1(Spec.G1.x + Spec.P, Spec.G1.y),
            b"",
            id="inf_plus_Pplus1_2",
        ),
        pytest.param(
            Spec.INF_G1 + PointG1(Spec.G1.x, Spec.G1.y + Spec.P),
            b"",
            id="inf_plus_1_Pplus2",
        ),
        pytest.param(
            PointG1(Spec.P, 0) + Spec.INF_G1,
            b"",
            id="P_0_plus_inf",
        ),
        pytest.param(
            PointG1(0, Spec.P) + Spec.INF_G1,
            b"",
            id="0_P_plus_inf",
        ),
        pytest.param(
            Spec.INF_G1 + PointG1(Spec.P, 0),
            b"",
            id="inf_plus_P_0",
        ),
        pytest.param(
            Spec.INF_G1 + PointG1(0, Spec.P),
            b"",
            id="inf_plus_0_P",
        ),
        pytest.param(
            Spec.S1 + Spec.S1_INVALID,
            b"",
            id="valid_plus_not_on_curve",
        ),
        pytest.param(
            Spec.S1_INVALID + Spec.S1,
            b"",
            id="not_on_curve_plus_valid",
        ),
        pytest.param(
            Spec.S1_INVALID + Spec.S1_INVALID,
            b"",
            id="not_on_curve_plus_not_on_curve",
        ),
    ],
)
@pytest.mark.ported_from(
    [
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge/pointAddFiller.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge/pointAddTruncFiller.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_0-0_1-3_21000_128Filler.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_0-0_1-3_25000_128Filler.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_0-3_1-2_21000_128Filler.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_0-3_1-2_25000_128Filler.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_1-3_0-0_21000_80Filler.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_1-3_0-0_25000_80_ParisFiller.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_6-9_19274124-124124_21000_128Filler.json",
        "https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stZeroKnowledge2/ecadd_6-9_19274124-124124_25000_128Filler.json",
    ],
    pr=[
        "https://github.com/ethereum/execution-specs/pull/1935",
        "https://github.com/ethereum/execution-specs/pull/2477",
    ],
)
@pytest.mark.eels_base_coverage
def test_invalid(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
) -> None:
    """Test the invalid inputs to the ECADD precompile."""
    state_test(pre=pre, tx=tx, post=post)

Parametrized Test Cases

This test generates 18 parametrized test cases across 13 forks.