Skip to content

Commit 4181649

Browse files
LouisTsai-CsieCarsons-Eels
authored andcommitted
feat(zkevm): add p256verify to worst compute tests (ethereum#1744)
* feat(zkevm): add p256verify to worst compute tests * refactor(tests): include FieldElement in worst compute test parameter validation * refactor(zkevm): skip test if precompile not enabled in fork
1 parent 0c00c94 commit 4181649

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

tests/zkevm/test_worst_compute.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
from tests.cancun.eip4844_blobs.spec import Spec as BlobsSpec
3535
from tests.istanbul.eip152_blake2.common import Blake2bInput
3636
from tests.istanbul.eip152_blake2.spec import Spec as Blake2bSpec
37+
from tests.osaka.eip7951_p256verify_precompiles import spec as p256verify_spec
38+
from tests.osaka.eip7951_p256verify_precompiles.spec import FieldElement
3739
from tests.prague.eip2537_bls_12_381_precompiles import spec as bls12381_spec
3840
from tests.prague.eip2537_bls_12_381_precompiles.spec import BytesConcatenation
3941

@@ -680,6 +682,17 @@ def test_worst_modexp(state_test: StateTestFiller, pre: Alloc, fork: Fork):
680682
],
681683
id="bls12_fp_to_g2",
682684
),
685+
pytest.param(
686+
p256verify_spec.Spec.P256VERIFY,
687+
[
688+
p256verify_spec.Spec.H0,
689+
p256verify_spec.Spec.R0,
690+
p256verify_spec.Spec.S0,
691+
p256verify_spec.Spec.X0,
692+
p256verify_spec.Spec.Y0,
693+
],
694+
id="p256verify",
695+
),
683696
],
684697
)
685698
@pytest.mark.slow()
@@ -693,20 +706,23 @@ def test_worst_precompile_fixed_cost(
693706
"""Test running a block filled with a precompile with fixed cost."""
694707
env = Environment()
695708

709+
if precompile_address not in fork.precompiles():
710+
pytest.skip("Precompile not enabled")
711+
696712
concatenated_bytes: bytes
697713
if all(isinstance(p, str) for p in parameters):
698714
parameters_str = cast(list[str], parameters)
699715
concatenated_hex_string = "".join(parameters_str)
700716
concatenated_bytes = bytes.fromhex(concatenated_hex_string)
701-
elif all(isinstance(p, (bytes, BytesConcatenation)) for p in parameters):
717+
elif all(isinstance(p, (bytes, BytesConcatenation, FieldElement)) for p in parameters):
702718
parameters_bytes_list = [
703-
bytes(p) for p in cast(list[BytesConcatenation | bytes], parameters)
719+
bytes(p) for p in cast(list[BytesConcatenation | bytes | FieldElement], parameters)
704720
]
705721
concatenated_bytes = b"".join(parameters_bytes_list)
706722
else:
707723
raise TypeError(
708724
"parameters must be a list of strings (hex) "
709-
"or a list of byte-like objects (bytes or BytesConcatenation)."
725+
"or a list of byte-like objects (bytes, BytesConcatenation or FieldElement)."
710726
)
711727

712728
padding_length = (32 - (len(concatenated_bytes) % 32)) % 32

0 commit comments

Comments
 (0)