55""" # noqa: E501
66
77from itertools import permutations
8- from typing import Any , Dict , Generator , List , Tuple
8+ from typing import Dict , Generator , List , Tuple
99
1010import pytest
1111
2626 Transaction ,
2727)
2828from ethereum_test_tools import Opcodes as Op
29+ from ethereum_test_tools .utility .pytest import ParameterSet
2930
3031from ..eip6110_deposits .helpers import DepositContract , DepositRequest , DepositTransaction
3132from ..eip6110_deposits .spec import Spec as Spec_EIP6110
@@ -99,7 +100,13 @@ def single_consolidation_from_contract(i: int) -> ConsolidationRequestContract:
99100 return ConsolidationRequestContract (requests = [single_consolidation (i )])
100101
101102
102- def get_permutations (n : int = 3 ) -> Generator [Any , None , None ]:
103+ def get_permutations (
104+ n : int = 3 ,
105+ ) -> Generator [
106+ ParameterSet ,
107+ None ,
108+ None ,
109+ ]:
103110 """Return possible permutations of the requests from an EOA."""
104111 requests = [
105112 (
@@ -119,7 +126,7 @@ def get_permutations(n: int = 3) -> Generator[Any, None, None]:
119126 yield pytest .param ([p [1 ] for p in perm ], id = "+" .join ([p [0 ] for p in perm ]))
120127
121128
122- def get_eoa_permutations (n : int = 3 ) -> Generator [Any , None , None ]:
129+ def get_eoa_permutations (n : int = 3 ) -> Generator [ParameterSet , None , None ]:
123130 """Return possible permutations of the requests from an EOA."""
124131 requests = [
125132 (
@@ -139,7 +146,7 @@ def get_eoa_permutations(n: int = 3) -> Generator[Any, None, None]:
139146 yield pytest .param ([p [1 ] for p in perm ], id = "+" .join ([p [0 ] for p in perm ]))
140147
141148
142- def get_contract_permutations (n : int = 3 ) -> Generator [Any , None , None ]:
149+ def get_contract_permutations (n : int = 3 ) -> Generator [ParameterSet , None , None ]:
143150 """Return possible permutations of the requests from a contract."""
144151 requests = [
145152 (
@@ -172,14 +179,6 @@ def get_contract_permutations(n: int = 3) -> Generator[Any, None, None]:
172179 ],
173180 id = "deposit_from_eoa+withdrawal_from_eoa+deposit_from_contract" ,
174181 ),
175- pytest .param (
176- [
177- single_withdrawal_from_eoa (0 ),
178- single_deposit_from_eoa (0 ),
179- single_withdrawal_from_contract (1 ),
180- ],
181- id = "withdrawal_from_eoa+deposit_from_eoa+withdrawal_from_contract" ,
182- ),
183182 pytest .param (
184183 [
185184 single_deposit_from_eoa (0 ),
@@ -214,10 +213,138 @@ def get_contract_permutations(n: int = 3) -> Generator[Any, None, None]:
214213 ],
215214 id = "withdrawal_from_eoa+consolidation_from_eoa+withdrawal_from_contract" ,
216215 ),
216+ pytest .param (
217+ [
218+ single_withdrawal_from_eoa (0 ),
219+ single_deposit_from_eoa (0 ),
220+ single_withdrawal_from_contract (1 ),
221+ ],
222+ id = "withdrawal_from_eoa+deposit_from_eoa+withdrawal_from_contract" ,
223+ ),
217224 pytest .param (
218225 [],
219226 id = "empty_requests" ,
220227 ),
228+ ###################### contract: consolidation + withdrawal
229+ pytest .param (
230+ [
231+ single_withdrawal_from_eoa (0 ),
232+ single_consolidation_from_contract (0 ),
233+ single_withdrawal_from_contract (1 ),
234+ ],
235+ id = "withdrawal_from_eoa+consolidation_from_contract+withdrawal_from_contract" ,
236+ ),
237+ pytest .param (
238+ [
239+ single_deposit_from_eoa (0 ),
240+ single_consolidation_from_contract (0 ),
241+ single_withdrawal_from_contract (0 ),
242+ ],
243+ id = "deposit_from_eoa+consolidation_from_contract+withdrawal_from_contract" ,
244+ ),
245+ pytest .param (
246+ [
247+ single_consolidation_from_eoa (0 ),
248+ single_consolidation_from_contract (1 ),
249+ single_withdrawal_from_contract (0 ),
250+ ],
251+ id = "consolidation_from_eoa+consolidation_from_contract+withdrawal_from_contract" ,
252+ ),
253+ ###################### contract: consolidation + deposit
254+ pytest .param (
255+ [
256+ single_withdrawal_from_eoa (0 ),
257+ single_consolidation_from_contract (0 ),
258+ single_deposit_from_contract (0 ),
259+ ],
260+ id = "withdrawal_from_eoa+consolidation_from_contract+deposit_from_contract" ,
261+ ),
262+ pytest .param (
263+ [
264+ single_deposit_from_eoa (0 ),
265+ single_consolidation_from_contract (0 ),
266+ single_deposit_from_contract (1 ),
267+ ],
268+ id = "deposit_from_eoa+consolidation_from_contract+deposit_from_contract" ,
269+ ),
270+ pytest .param (
271+ [
272+ single_consolidation_from_eoa (0 ),
273+ single_consolidation_from_contract (1 ),
274+ single_deposit_from_contract (0 ),
275+ ],
276+ id = "consolidation_from_eoa+consolidation_from_contract+deposit_from_contract" ,
277+ ),
278+ ###################### contract: withdrawal + deposit
279+ pytest .param (
280+ [
281+ single_withdrawal_from_eoa (0 ),
282+ single_withdrawal_from_contract (1 ),
283+ single_deposit_from_contract (0 ),
284+ ],
285+ id = "withdrawal_from_eoa+withdrawal_from_contract+deposit_from_contract" ,
286+ ),
287+ pytest .param (
288+ [
289+ single_deposit_from_eoa (0 ),
290+ single_withdrawal_from_contract (0 ),
291+ single_deposit_from_contract (1 ),
292+ ],
293+ id = "deposit_from_eoa+withdrawal_from_contract+deposit_from_contract" ,
294+ ),
295+ pytest .param (
296+ [
297+ single_consolidation_from_eoa (0 ),
298+ single_withdrawal_from_contract (0 ),
299+ single_deposit_from_contract (0 ),
300+ ],
301+ id = "consolidation_from_eoa+withdrawal_from_contract+deposit_from_contract" ,
302+ ),
303+ # testing upper limits of each request type per slot if it exists
304+ pytest .param (
305+ [
306+ single_consolidation_from_contract (0 ),
307+ single_consolidation_from_contract (1 ),
308+ # single_consolidation_from_contract(2), # i=2 is not allowed cuz only 2 MAX CONSOLIDATIONS PER BLOCK (EIP-7251), but why does the error message not inform about this? only reports hash mismatch # noqa: E501
309+ #
310+ # the following performs single_withdrawal_from_contract(0) to (16)
311+ * [
312+ single_withdrawal_from_contract (i )
313+ for i in range (
314+ 0 ,
315+ 16 , # ensure that the hard limit of deposits per epoch has been removed
316+ # in all clients (EIP-6610), prev limit was
317+ # 16 deposits/slot or 512 deposits/epoch
318+ ) # when using larger numbers: it fails around 1000 due to:
319+ # UnixHTTPConnectionPool(host='localhost', port=None):
320+ # Read timed out. (read timeout=20), workaround: in transition_tool.py
321+ # use SLOW_REQUEST_TIMEOUT (60 sec), so slow=True
322+ ],
323+ # single_withdrawal_from_contract(16), # i=16 not allowed cuz only
324+ # 16 MAX WITHDRAWALS PER BLOCK (EIP-7002)
325+ #
326+ # the following performs single_deposit_from_contract(0) to (18)
327+ * [
328+ single_deposit_from_contract (i )
329+ for i in range (
330+ 0 ,
331+ 18 , # ensure that the hard limit of deposits per epoch has been removed
332+ # in all clients (EIP-6610), prev limit was 16 deposits/slot
333+ # or 512 deposits/epoch
334+ ) # when using larger numbers: it fails around 1000 due to:
335+ # UnixHTTPConnectionPool(host='localhost', port=None): Read timed out.
336+ # (read timeout=20), workaround: in transition_tool.py use
337+ # SLOW_REQUEST_TIMEOUT (60 sec), so slow=True
338+ ],
339+ ],
340+ # following ID not possible to due filename length limitations
341+ # id=(
342+ # ("consolidation_from_contract+" * 2)
343+ # + ("withdrawal_from_contract+" * 16)
344+ # + ("deposit_from_contract+" * 18)
345+ # )[:-1], # remove last '+'
346+ id = "max_withdrawals_per_slot+max_consolidations_per_slot+unlimited_deposits_per_slot" ,
347+ ),
221348 ],
222349)
223350def test_valid_deposit_withdrawal_consolidation_requests (
@@ -324,7 +451,7 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
324451 )
325452
326453
327- def invalid_requests_block_combinations (fork : Fork ) -> List [Any ]:
454+ def invalid_requests_block_combinations (fork : Fork ) -> List [ParameterSet ]:
328455 """
329456 Return a list of invalid request combinations for the given fork.
330457
0 commit comments