Skip to content

test_valid()

Documentation for tests/byzantium/eip196_ec_add_mul/test_ecadd.py::test_valid@7b8124a7.

Generate fixtures for these test cases for Osaka with:

fill -v tests/byzantium/eip196_ec_add_mul/test_ecadd.py::test_valid --fork Osaka

Test the valid inputs to the ECADD precompile.

Source code in tests/byzantium/eip196_ec_add_mul/test_ecadd.py
 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
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
@pytest.mark.parametrize(
    "input_data, expected_output",
    [
        pytest.param(
            Spec.G1 + Spec.INF_G1,
            Spec.G1,
            id="generator_plus_inf",
        ),
        pytest.param(
            Spec.INF_G1 + Spec.G1,
            Spec.G1,
            id="inf_plus_generator",
        ),
        pytest.param(
            Spec.G1 + Spec.INF_G1 + Spec.INF_G1,
            Spec.G1,
            id="generator_plus_inf_extra_inf",
        ),
        pytest.param(
            Spec.INF_G1 + Spec.G1 + Spec.INF_G1,
            Spec.G1,
            id="inf_plus_generator_extra_inf",
        ),
        pytest.param(
            b"",
            Spec.INF_G1,
            id="empty",
        ),
        pytest.param(
            Spec.INF_G1,
            Spec.INF_G1,
            id="single_inf",
        ),
        pytest.param(
            Spec.INF_G1 + Spec.INF_G1,
            Spec.INF_G1,
            id="double_inf",
        ),
        pytest.param(
            Spec.INF_G1 + Spec.INF_G1 + Spec.INF_G1,
            Spec.INF_G1,
            id="triple_inf",
        ),
        pytest.param(
            bytes(Spec.INF_G1)[:-1],
            Spec.INF_G1,
            id="inf_minus_1_byte",
        ),
        pytest.param(
            Spec.INF_G1 + b"\0" * 1,
            Spec.INF_G1,
            id="inf_plus_1_zero_byte",
        ),
        pytest.param(
            Spec.INF_G1 + Spec.INF_G1 + b"\0" * 1,
            Spec.INF_G1,
            id="double_inf_plus_1_zero_byte",
        ),
        pytest.param(
            b"\0" * 80,
            Spec.INF_G1,
            id="80_zero_bytes",
        ),
        pytest.param(
            Spec.G1,
            Spec.G1,
            id="single_generator",
        ),
        pytest.param(
            Spec.G1 + Spec.G1,
            Spec.G1x2,
            id="double_generator",
        ),
        pytest.param(
            Spec.G1 + Spec.G1 + Spec.G1,
            Spec.G1x2,  # Last generator is ignored data
            id="triple_generator",
        ),
        pytest.param(
            Spec.G1 + Spec.G1 + Spec.INF_G1,
            Spec.G1x2,
            id="double_generator_extra_inf",
        ),
        pytest.param(
            Spec.G1 + Spec.G1 + PointG1(1, 3),
            Spec.G1x2,  # Extra invalid point is ignored
            id="double_generator_extra_pt_1_3",
        ),
        pytest.param(
            Spec.P1 + Spec.Q1,
            Spec.R1,
            id="p1_plus_q1",
        ),
        pytest.param(
            Spec.P1 + PointG1(Spec.P1.x, Spec.P - Spec.P1.y),
            Spec.INF_G1,
            id="p1_plus_neg_p1",
        ),
    ],
)
@pytest.mark.ported_from(
    [
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_21000_0Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_21000_64Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_21000_80_ParisFiller.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_21000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_21000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_25000_0Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_25000_64Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_25000_80Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_25000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_0-0_25000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_1-2_21000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_1-2_21000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_1-2_25000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_0-0_1-2_25000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_0-0_21000_64Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_0-0_21000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_0-0_21000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_0-0_25000_64Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_0-0_25000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_0-0_25000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_1-2_21000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_1-2_21000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_1-2_25000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1-2_1-2_25000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1145-3932_1145-4651_21000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1145-3932_1145-4651_25000_192Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1145-3932_2969-1336_21000_128Filler.json"
        "https://github.com/ethereum/legacytests/tree/master/Cancun/GeneralStateTests/stZeroKnowledge2/ecadd_1145-3932_2969-1336_25000_128Filler.json"
    ],
    pr=["https://github.com/ethereum/execution-specs/pull/1935"],
)
def test_valid(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
) -> None:
    """Test the valid inputs to the ECADD precompile."""
    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test generates 19 parametrized test cases across 11 forks.