Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions tests/zkevm/test_worst_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from tests.cancun.eip4844_blobs.spec import Spec as BlobsSpec
from tests.istanbul.eip152_blake2.common import Blake2bInput
from tests.istanbul.eip152_blake2.spec import Spec as Blake2bSpec
from tests.osaka.eip7951_p256verify_precompiles import spec as p256verify_spec
from tests.osaka.eip7951_p256verify_precompiles.spec import FieldElement
from tests.prague.eip2537_bls_12_381_precompiles import spec as bls12381_spec
from tests.prague.eip2537_bls_12_381_precompiles.spec import BytesConcatenation

Expand Down Expand Up @@ -680,6 +682,17 @@ def test_worst_modexp(state_test: StateTestFiller, pre: Alloc, fork: Fork):
],
id="bls12_fp_to_g2",
),
pytest.param(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is going to pass but the test is only going to test empty account calls because there's no precompile here prior to Prague.

We should test whether precompile_address is in fork.precompiles(), and if not just pytest.skip("Precompile not enabled") at the start of the function.

p256verify_spec.Spec.P256VERIFY,
[
p256verify_spec.Spec.H0,
p256verify_spec.Spec.R0,
p256verify_spec.Spec.S0,
p256verify_spec.Spec.X0,
p256verify_spec.Spec.Y0,
],
id="p256verify",
),
],
)
@pytest.mark.slow()
Expand All @@ -693,20 +706,23 @@ def test_worst_precompile_fixed_cost(
"""Test running a block filled with a precompile with fixed cost."""
env = Environment()

if precompile_address not in fork.precompiles():
pytest.skip("Precompile not enabled")

concatenated_bytes: bytes
if all(isinstance(p, str) for p in parameters):
parameters_str = cast(list[str], parameters)
concatenated_hex_string = "".join(parameters_str)
concatenated_bytes = bytes.fromhex(concatenated_hex_string)
elif all(isinstance(p, (bytes, BytesConcatenation)) for p in parameters):
elif all(isinstance(p, (bytes, BytesConcatenation, FieldElement)) for p in parameters):
parameters_bytes_list = [
bytes(p) for p in cast(list[BytesConcatenation | bytes], parameters)
bytes(p) for p in cast(list[BytesConcatenation | bytes | FieldElement], parameters)
]
concatenated_bytes = b"".join(parameters_bytes_list)
else:
raise TypeError(
"parameters must be a list of strings (hex) "
"or a list of byte-like objects (bytes or BytesConcatenation)."
"or a list of byte-like objects (bytes, BytesConcatenation or FieldElement)."
)

padding_length = (32 - (len(concatenated_bytes) % 32)) % 32
Expand Down
Loading