diff --git a/tests/byzantium/eip198_modexp_precompile/test_modexp.py b/tests/byzantium/eip198_modexp_precompile/test_modexp.py index 5d103fbf59..55229877a7 100644 --- a/tests/byzantium/eip198_modexp_precompile/test_modexp.py +++ b/tests/byzantium/eip198_modexp_precompile/test_modexp.py @@ -16,6 +16,9 @@ Transaction, compute_create_address, ) +from execution_testing.base_types.base_types import ( + FixedSizeBytes, +) from .helpers import ModExpInput, ModExpOutput @@ -146,35 +149,32 @@ id="EIP-198-case5-raw-input", ), # different declared moduli lengths and parities - pytest.param( - ModExpInput( - base="1234", - exponent="234", - modulus="1000", - declared_modulus_length=256, - ), - ModExpOutput( - returned_data=Bytes( - "07be9ec040921bf6ffa9faad54b5e88c503ea4511cc15505e36fc9569cf20698" - "933819b8c4b15e52a51f64261954708f55432c5a7011dc7d1787c64a8ece6f20" - "65772d1dbc3ea9e96e3f55eeec7477bc92cb587ae416c8316fb3fa825ee25410" - "811fad4f98ade2eaa665b48e930247bb30b25100000000000000000000000000" - + (256 - 4 * 32) - * "00" - ) - ), - id="EIP-198-case1-mod-power2-declared-length-256-bytes", - ), - pytest.param( - ModExpInput( - base="1234", - exponent="234", - modulus="1010", - declared_modulus_length=128, - ), - ModExpOutput(returned_data=Bytes("00") + Bytes(hex(2**1014))), - id="EIP-198-case1-mod-even-declared-length-128-bytes", - ), + *[ + pytest.param( + ModExpInput( + base="1234", + exponent="234", + modulus="1000" if parity == "power2" else "1010", + declared_modulus_length=width, + ), + ModExpOutput( + returned_data=FixedSizeBytes[width]( # type: ignore + ( + (0x1234**0x234) + % ( + (0x1000 if parity == "power2" else 0x1010) + # declared `width` bitshifts modulus left. + << ((width - 2) * 8) + ) + ), + left_padding=True, + ) + ), + id=f"EIP-198-case1-mod-{parity}-declared-length-{width}-bytes", + ) + for width in [64, 128, 256, 512] + for parity in ["power2", "even"] + ], # out of gas cases pytest.param( Bytes(