Skip to content

Commit 7c4ea0f

Browse files
committed
new(tests): added more cases (two contract req, one EOA req) in test_valid_deposit_withdrawal_consolidation_requests
1 parent 2c07538 commit 7c4ea0f

File tree

1 file changed

+142
-13
lines changed

1 file changed

+142
-13
lines changed

tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py

Lines changed: 142 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
""" # noqa: E501
66

77
from itertools import permutations
8-
from typing import Any, Dict, Generator, List, Tuple
8+
from typing import Dict, Generator, List, Tuple
99

1010
import pytest
1111

@@ -26,6 +26,7 @@
2626
Transaction,
2727
)
2828
from ethereum_test_tools import Opcodes as Op
29+
from ethereum_test_tools.utility.pytest import ParameterSet
2930

3031
from ..eip6110_deposits.helpers import DepositContract, DepositRequest, DepositTransaction
3132
from ..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,140 @@ 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
309+
# only 2 MAX CONSOLIDATIONS PER BLOCK (EIP-7251), but why does the error message
310+
# not inform about this? only reports hash mismatch
311+
#
312+
# the following performs single_withdrawal_from_contract(0) to (16)
313+
*[
314+
single_withdrawal_from_contract(i)
315+
for i in range(
316+
0,
317+
16, # ensure that the hard limit of deposits per epoch has been removed
318+
# in all clients (EIP-6610), prev limit was
319+
# 16 deposits/slot or 512 deposits/epoch
320+
) # when using larger numbers: it fails around 1000 due to:
321+
# UnixHTTPConnectionPool(host='localhost', port=None):
322+
# Read timed out. (read timeout=20), workaround: in transition_tool.py
323+
# use SLOW_REQUEST_TIMEOUT (60 sec), so slow=True
324+
],
325+
# single_withdrawal_from_contract(16), # i=16 not allowed cuz only
326+
# 16 MAX WITHDRAWALS PER BLOCK (EIP-7002)
327+
#
328+
# the following performs single_deposit_from_contract(0) to (18)
329+
*[
330+
single_deposit_from_contract(i)
331+
for i in range(
332+
0,
333+
18, # ensure that the hard limit of deposits per epoch has been removed
334+
# in all clients (EIP-6610), prev limit was 16 deposits/slot
335+
# or 512 deposits/epoch
336+
) # when using larger numbers: it fails around 1000 due to:
337+
# UnixHTTPConnectionPool(host='localhost', port=None): Read timed out.
338+
# (read timeout=20), workaround: in transition_tool.py use
339+
# SLOW_REQUEST_TIMEOUT (60 sec), so slow=True
340+
],
341+
],
342+
# following ID not possible to due filename length limitations
343+
# id=(
344+
# ("consolidation_from_contract+" * 2)
345+
# + ("withdrawal_from_contract+" * 16)
346+
# + ("deposit_from_contract+" * 18)
347+
# )[:-1], # remove last '+'
348+
id="max_withdrawals_per_slot+max_consolidations_per_slot+unlimited_deposits_per_slot",
349+
),
221350
],
222351
)
223352
def test_valid_deposit_withdrawal_consolidation_requests(
@@ -324,7 +453,7 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
324453
)
325454

326455

327-
def invalid_requests_block_combinations(fork: Fork) -> List[Any]:
456+
def invalid_requests_block_combinations(fork: Fork) -> List[ParameterSet]:
328457
"""
329458
Return a list of invalid request combinations for the given fork.
330459

0 commit comments

Comments
 (0)