Skip to content

Commit d52d458

Browse files
committed
lints
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent 14a811c commit d52d458

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tests/zkevm/test_worst_compute.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
import math
9-
from typing import SupportsBytes
9+
from typing import cast
1010

1111
import pytest
1212

@@ -337,7 +337,7 @@ def test_worst_modexp(
337337
pytest.param(
338338
bls12381_spec.Spec.G2MSM,
339339
[
340-
# TODO: the //2 is only required due to a limitation of the max contract size limit.
340+
# TODO: the //2 is required due to a limitation of the max contract size limit.
341341
# In a further iteration we can insert the inputs as calldata or storage and avoid
342342
# having to do PUSHes which has this limtiation. This also applies to G1MSM.
343343
(bls12381_spec.Spec.P2 + bls12381_spec.Scalar(bls12381_spec.Spec.Q))
@@ -348,7 +348,8 @@ def test_worst_modexp(
348348
pytest.param(
349349
bls12381_spec.Spec.PAIRING,
350350
[
351-
bls12381_spec.Spec.G1 + bls12381_spec.Spec.INF_G2,
351+
bls12381_spec.Spec.G1,
352+
bls12381_spec.Spec.G2,
352353
],
353354
id="bls12_pairing_check",
354355
),
@@ -373,17 +374,24 @@ def test_worst_precompile_fixed_cost(
373374
pre: Alloc,
374375
fork: Fork,
375376
precompile_address: Address,
376-
parameters: list[str] | list[BytesConcatenation],
377+
parameters: list[str] | list[BytesConcatenation] | list[bytes],
377378
):
378379
"""Test running a block filled with a precompile with fixed cost."""
379380
env = Environment()
380381

381-
concatenated_bytes = bytes()
382-
if isinstance(parameters[0], str):
383-
concatenated_hex_string = "".join(parameters)
382+
concatenated_bytes: bytes
383+
if all(isinstance(p, str) for p in parameters):
384+
parameters_str = cast(list[str], parameters)
385+
concatenated_hex_string = "".join(parameters_str)
384386
concatenated_bytes = bytes.fromhex(concatenated_hex_string)
387+
elif all(isinstance(p, (bytes, BytesConcatenation)) for p in parameters):
388+
parameters_bytes_list = [bytes(p) for p in parameters]
389+
concatenated_bytes = b"".join(parameters_bytes_list)
385390
else:
386-
concatenated_bytes = b"".join(bytes(p) for p in parameters)
391+
raise TypeError(
392+
"parameters must be a list of strings (hex) "
393+
"or a list of byte-like objects (bytes or BytesConcatenation)."
394+
)
387395

388396
padding_length = (32 - (len(concatenated_bytes) % 32)) % 32
389397
input_bytes = concatenated_bytes + b"\x00" * padding_length

0 commit comments

Comments
 (0)