|
16 | 16 | Transaction, |
17 | 17 | compute_create_address, |
18 | 18 | ) |
| 19 | +from execution_testing.base_types.base_types import ( |
| 20 | + FixedSizeBytes, |
| 21 | +) |
19 | 22 |
|
20 | 23 | from .helpers import ModExpInput, ModExpOutput |
21 | 24 |
|
|
146 | 149 | id="EIP-198-case5-raw-input", |
147 | 150 | ), |
148 | 151 | # different declared moduli lengths and parities |
149 | | - pytest.param( |
150 | | - ModExpInput( |
151 | | - base="1234", |
152 | | - exponent="234", |
153 | | - modulus="1000", |
154 | | - declared_modulus_length=256, |
155 | | - ), |
156 | | - ModExpOutput( |
157 | | - returned_data=Bytes( |
158 | | - "07be9ec040921bf6ffa9faad54b5e88c503ea4511cc15505e36fc9569cf20698" |
159 | | - "933819b8c4b15e52a51f64261954708f55432c5a7011dc7d1787c64a8ece6f20" |
160 | | - "65772d1dbc3ea9e96e3f55eeec7477bc92cb587ae416c8316fb3fa825ee25410" |
161 | | - "811fad4f98ade2eaa665b48e930247bb30b25100000000000000000000000000" |
162 | | - + (256 - 4 * 32) |
163 | | - * "00" |
164 | | - ) |
165 | | - ), |
166 | | - id="EIP-198-case1-mod-power2-declared-length-256-bytes", |
167 | | - ), |
168 | | - pytest.param( |
169 | | - ModExpInput( |
170 | | - base="1234", |
171 | | - exponent="234", |
172 | | - modulus="1010", |
173 | | - declared_modulus_length=128, |
174 | | - ), |
175 | | - ModExpOutput(returned_data=Bytes("00") + Bytes(hex(2**1014))), |
176 | | - id="EIP-198-case1-mod-even-declared-length-128-bytes", |
177 | | - ), |
| 152 | + *[ |
| 153 | + pytest.param( |
| 154 | + ModExpInput( |
| 155 | + base="1234", |
| 156 | + exponent="234", |
| 157 | + modulus="1000" if parity == "power2" else "1010", |
| 158 | + declared_modulus_length=width, |
| 159 | + ), |
| 160 | + ModExpOutput( |
| 161 | + returned_data=FixedSizeBytes[width]( # type: ignore |
| 162 | + ( |
| 163 | + (0x1234**0x234) |
| 164 | + % ( |
| 165 | + (0x1000 if parity == "power2" else 0x1010) |
| 166 | + # declared `width` bitshifts modulus left. |
| 167 | + << ((width - 2) * 8) |
| 168 | + ) |
| 169 | + ), |
| 170 | + left_padding=True, |
| 171 | + ) |
| 172 | + ), |
| 173 | + id=f"EIP-198-case1-mod-{parity}-declared-length-{width}-bytes", |
| 174 | + ) |
| 175 | + for width in [64, 128, 256, 512] |
| 176 | + for parity in ["power2", "even"] |
| 177 | + ], |
178 | 178 | # out of gas cases |
179 | 179 | pytest.param( |
180 | 180 | Bytes( |
|
0 commit comments