Skip to content

Commit c4b336b

Browse files
test: add extra invalid cases
1 parent 05feea2 commit c4b336b

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,56 @@ def test_vectors_from_file(
4747
"modexp_input,modexp_expected,call_succeeds",
4848
[
4949
pytest.param(bytes(), bytes(), False, id="zero-length-calldata"),
50+
pytest.param(
51+
bytes.fromhex(
52+
format(10, "032x") # Bsize
53+
+ format(11, "032x") # Esize
54+
+ format(12, "032x") # Msize
55+
+ "FF" * 9 # E
56+
+ "FF" * 11 # M
57+
+ "FF" * 12 # B
58+
),
59+
bytes(),
60+
False,
61+
id="b-too-short",
62+
),
63+
pytest.param(
64+
bytes.fromhex(
65+
format(10, "032x") # Bsize
66+
+ format(11, "032x") # Esize
67+
+ format(12, "032x") # Msize
68+
+ "FF" * 10 # E
69+
+ "FF" * 10 # M
70+
+ "FF" * 12 # B
71+
),
72+
bytes(),
73+
False,
74+
id="m-too-short",
75+
),
76+
pytest.param(
77+
bytes.fromhex(
78+
format(10, "032x") # Bsize
79+
+ format(11, "032x") # Esize
80+
+ format(12, "032x") # Msize
81+
+ "FF" * 10 # E
82+
+ "FF" * 11 # M
83+
+ "FF" * 11 # B
84+
),
85+
bytes(),
86+
False,
87+
id="e-too-short",
88+
),
89+
# Not sure if this is valid
90+
pytest.param(
91+
bytes.fromhex(
92+
format(0, "032x") # Bsize
93+
+ format(0, "032x") # Esize
94+
+ format(0, "032x") # Msize
95+
),
96+
bytes(),
97+
False,
98+
id="all-zeros",
99+
),
50100
],
51101
)
52102
@EIPChecklist.Precompile.Test.Inputs.AllZeros
@@ -134,3 +184,46 @@ def test_modexp_gas_usage(
134184
):
135185
"""Test ModExp gas cost using the test vectors from EIP-7883."""
136186
state_test(pre=pre, tx=tx, post=post)
187+
188+
189+
@pytest.mark.parametrize(
190+
"modexp_input,modexp_expected,precompile_gas_modifier,call_succeeds",
191+
[
192+
pytest.param(
193+
Spec.modexp_input,
194+
Spec.modexp_expected,
195+
1,
196+
True,
197+
id="extra_gas",
198+
),
199+
pytest.param(
200+
Spec.modexp_input,
201+
Spec.modexp_expected,
202+
0,
203+
True,
204+
id="exact_gas",
205+
),
206+
pytest.param(
207+
Spec.modexp_input,
208+
Spec.modexp_error,
209+
-1,
210+
False,
211+
id="insufficient_gas",
212+
),
213+
],
214+
)
215+
def test_modexp_entry_points(
216+
state_test: StateTestFiller,
217+
pre: Alloc,
218+
tx: Transaction,
219+
modexp_input: bytes,
220+
tx_gas_limit: int,
221+
):
222+
"""Test ModExp entry points."""
223+
tx = Transaction(
224+
to=Spec.MODEXP_ADDRESS,
225+
sender=pre.fund_eoa(),
226+
data=bytes(modexp_input),
227+
gas_limit=tx_gas_limit,
228+
)
229+
state_test(pre=pre, tx=tx, post={})

0 commit comments

Comments
 (0)