Skip to content

Commit c4bf3e1

Browse files
committed
new(tests): added more cases (two contract req, one EOA req) in test_valid_deposit_withdrawal_consolidation_requests
1 parent fc25f0c commit c4bf3e1

File tree

1 file changed

+103
-13
lines changed

1 file changed

+103
-13
lines changed

tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py

Lines changed: 103 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,101 @@ 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(1),
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(1),
241+
single_withdrawal_from_contract(1),
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(1),
250+
],
251+
id="consolidation_from_eoa+consolidation_from_contract+withdrawal_from_contract",
252+
),
253+
###################### contract: consolidation + deposit
254+
pytest.param( # TODO: why do i have to put 0 for contract deposit here?
255+
[
256+
single_withdrawal_from_eoa(0),
257+
single_consolidation_from_contract(1),
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(1),
266+
single_deposit_from_contract(1),
267+
],
268+
id="deposit_from_eoa+consolidation_from_contract+deposit_from_contract",
269+
),
270+
pytest.param( # TODO: why do i have to put 0 for contract deposit here?
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( # TODO: why do i have to put 0 for contract deposit here?
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(1),
291+
single_deposit_from_contract(1),
292+
],
293+
id="deposit_from_eoa+withdrawal_from_contract+deposit_from_contract",
294+
),
295+
pytest.param( # TODO: why do i have to put 0 for contract deposit here?
296+
[
297+
single_consolidation_from_eoa(0),
298+
single_withdrawal_from_contract(1),
299+
single_deposit_from_contract(0),
300+
],
301+
id="consolidation_from_eoa+withdrawal_from_contract+deposit_from_contract",
302+
), # TODO: how to spot duplicates like the following? other than noticing fill number goes up by 1 but consume number doesn't increase # noqa: E501
303+
# pytest.param( # TODO: why do i have to put 0 for contract deposit here?
304+
# [
305+
# single_consolidation_from_eoa(0),
306+
# single_withdrawal_from_contract(1),
307+
# single_deposit_from_contract(0),
308+
# ],
309+
# id="consolidation_from_eoa+withdrawal_from_contract+deposit_from_contract",
310+
# ),
221311
],
222312
)
223313
def test_valid_deposit_withdrawal_consolidation_requests(
@@ -324,7 +414,7 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
324414
)
325415

326416

327-
def invalid_requests_block_combinations(fork: Fork) -> List[Any]:
417+
def invalid_requests_block_combinations(fork: Fork) -> List[ParameterSet]:
328418
"""
329419
Return a list of invalid request combinations for the given fork.
330420

0 commit comments

Comments
 (0)