Skip to content

Commit 41662bd

Browse files
committed
Add zero edge cases
1 parent 14ed88d commit 41662bd

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ def create_modexp_variable_gas_test_cases():
289289
# Test case definitions: (base, exponent, modulus, expected_result, test_id)
290290
test_cases = [
291291
("", "", "", "", "Z0"),
292+
("01" * 32, "00" * 32, "", "", "Z1"),
293+
("01" * 1024, "00" * 32, "", "", "Z2"),
294+
("01" * 32, "00" * 1024, "", "", "Z3"),
295+
("01" * 32, "00" * 1023 + "01", "", "", "Z4"),
296+
("", "", "01" * 32, "00" * 31 + "01", "Z5"),
297+
("", "01" * 32, "01" * 32, "00" * 32, "Z6"),
298+
("", "00" * 31 + "01", "01" * 1024, "00" * 1024, "Z7"),
292299
("01" * 16, "00" * 16, "02" * 16, "00" * 15 + "01", "S0"),
293300
("01" * 16, "00" * 15 + "03", "02" * 16, "01" * 16, "S1"),
294301
("01" * 32, "FF" * 32, "02" * 32, "01" * 32, "S2"),
@@ -307,9 +314,14 @@ def create_modexp_variable_gas_test_cases():
307314
("01" * 33, "01", "02" * 31, "00" * 29 + "01" * 2, "B2"),
308315
("01" * 33, "01", "02" * 33, "01" * 33, "B4"),
309316
# Zero value edge cases
310-
("00" * 32, "00" * 32, "01" * 32, "00" * 31 + "01", "Z1"),
311-
("01" * 32, "00" * 32, "00" * 32, "00" * 32, "Z2"),
312-
("00" * 32, "01" * 32, "02" * 32, "00" * 32, "Z3"),
317+
("00" * 32, "00" * 32, "01" * 32, "00" * 31 + "01", "Z8"),
318+
("01" * 32, "00" * 32, "00" * 32, "00" * 32, "Z9"),
319+
("00" * 32, "01" * 32, "02" * 32, "00" * 32, "Z10"),
320+
("00" * 32, "00" * 33, "01" * 32, "00" * 31 + "01", "Z11"),
321+
("00" * 32, "00" * 1024, "01" * 32, "00" * 31 + "01", "Z12"),
322+
("00" * 1024, "00" * 32, "01" * 32, "00" * 31 + "01", "Z13"),
323+
("01" * 32, "00" * 1024, "00" * 32, "00" * 32, "Z14"),
324+
("01" * 32, "00" * 31 + "01", "00" * 1024, "00" * 1024, "Z15"),
313325
# Maximum value stress tests
314326
("FF" * 64, "FF" * 64, "FF" * 64, "00" * 64, "M1"),
315327
("FF" * 32, "01", "FF" * 32, "00" * 32, "M2"),
@@ -356,6 +368,13 @@ def create_modexp_variable_gas_test_cases():
356368
# │ ID │ Comp │ Rel │ Iter │ Clamp │ Gas │ Description │
357369
# ├─────┼──────┼─────┼──────┼───────┼─────────┼───────────────────────────────────────────────┤
358370
# │ Z0 │ - │ - │ - │ - │ 500 │ Zero case – empty inputs │
371+
# │ Z1 │ S │ - │ A │ True │ 500 │ Non-zero base, zero exp, empty modulus │
372+
# │ Z2 │ L │ - │ A │ False │ 32768 │ Large base (1024B), zero exp, empty modulus │
373+
# │ Z3 │ S │ - │ C │ False │253936 │ Base, large zero exp (1024B), empty modulus │
374+
# │ Z4 │ S │ - │ D │ False │253952 │ Base, large exp (last byte=1), empty modulus │
375+
# │ Z5 │ S │ < │ A │ True │ 500 │ Empty base/exp, non-zero modulus only │
376+
# │ Z6 │ S │ < │ B │ False │ 3968 │ Empty base, non-zero exp and modulus │
377+
# │ Z7 │ L │ < │ B │ False │ 32768 │ Empty base, small exp, large modulus │
359378
# │ S0 │ S │ = │ A │ True │ 500 │ Small, equal, zero exp, clamped │
360379
# │ S1 │ S │ = │ B │ True │ 500 │ Small, equal, small exp, clamped │
361380
# │ S2 │ S │ = │ B │ False │ 4080 │ Small, equal, large exp, unclamped │
@@ -372,9 +391,14 @@ def create_modexp_variable_gas_test_cases():
372391
# │ B1 │ L │ < │ B │ True │ 500 │ Cross 32-byte boundary (31/33) │
373392
# │ B2 │ L │ > │ B │ True │ 500 │ Cross 32-byte boundary (33/31) │
374393
# │ B4 │ L │ = │ B │ True │ 500 │ Just over 32-byte boundary │
375-
# │ Z1 │ S │ = │ A │ True │ 500 │ All zeros except modulus │
376-
# │ Z2 │ S │ = │ A │ True │ 500 │ Zero modulus special case │
377-
# │ Z3 │ S │ = │ B │ False │ 3968 │ Zero base, large exponent │
394+
# │ Z8 │ S │ = │ A │ True │ 500 │ All zeros except modulus │
395+
# │ Z9 │ S │ = │ A │ True │ 500 │ Zero modulus special case │
396+
# │ Z10 │ S │ = │ B │ False │ 3968 │ Zero base, large exponent │
397+
# │ Z11 │ S │ = │ C │ True │ 500 │ Zero base, 33B zero exp, non-zero modulus │
398+
# │ Z12 │ S │ = │ C │ False │253936 │ Zero base, large zero exp, non-zero modulus │
399+
# │ Z13 │ L │ > │ A │ False │ 32768 │ Large zero base, zero exp, non-zero modulus │
400+
# │ Z14 │ S │ = │ C │ False │253936 │ Base, large zero exp, zero modulus │
401+
# │ Z15 │ L │ < │ B │ False │ 32768 │ Base, small exp, large zero modulus │
378402
# │ M1 │ L │ = │ D │ False │ 98176 │ Maximum values stress test │
379403
# │ M2 │ S │ = │ B │ True │ 500 │ Max base/mod, small exponent │
380404
# │ M3 │ L │ < │ D │ False │ 98176 │ Small base, max exponent/mod │

0 commit comments

Comments
 (0)