66
77from typing import List
88
9+ import pytest
10+
911from ethereum_test_tools import (
1012 Account ,
1113 Alloc ,
1517)
1618from ethereum_test_types import Requests
1719
18- from .. eip7002_el_triggerable_withdrawals . helpers import (
20+ from .helpers import (
1921 WithdrawalRequest ,
2022 # WithdrawalRequestBase,
2123 # WithdrawalRequestContract,
2224 WithdrawalRequestTransaction ,
2325)
24- from .. eip7002_el_triggerable_withdrawals . spec import Spec as Spec_EIP7002
26+ from .spec import Spec as Spec_EIP7002
2527from .spec import ref_spec_7002
2628
2729REFERENCE_SPEC_GIT_PATH : str = ref_spec_7002 .git_path
2830REFERENCE_SPEC_VERSION : str = ref_spec_7002 .version
2931
3032
31- # @pytest.mark.parametrize(
32- # "requests_list",
33- # [
34- # WithdrawalRequest(
35- # validator_pubkey=0x01,
36- # amount=0,
37- # fee=Spec_EIP7002.get_fee(0),
38- # ),
39- # WithdrawalRequest(
40- # validator_pubkey=0x01,
41- # amount=0,
42- # fee=Spec_EIP7002.get_fee(0),
43- # ),
44- # ],
45- # )
33+ def single_withdrawal_with_custom_fee (i : int ) -> WithdrawalRequest : # noqa: D103
34+ return WithdrawalRequest (
35+ validator_pubkey = i + 1 ,
36+ amount = 0 ,
37+ fee = Spec_EIP7002 .get_fee (0 ),
38+ )
39+
40+
41+ @pytest .mark .parametrize (
42+ "requests_list" ,
43+ [
44+ pytest .param (
45+ [
46+ * [
47+ single_withdrawal_with_custom_fee (i )
48+ for i in range (
49+ 0 ,
50+ 16 ,
51+ )
52+ ],
53+ ],
54+ id = "16_withdrawal_requests" ,
55+ ),
56+ pytest .param (
57+ [
58+ * [
59+ single_withdrawal_with_custom_fee (i )
60+ for i in range (
61+ 0 ,
62+ 17 ,
63+ )
64+ ],
65+ ],
66+ id = "17_withdrawal_requests" ,
67+ ),
68+ pytest .param (
69+ [
70+ * [
71+ single_withdrawal_with_custom_fee (i )
72+ for i in range (
73+ 0 ,
74+ 18 ,
75+ )
76+ ],
77+ ],
78+ id = "18_withdrawal_requests" ,
79+ ),
80+ ],
81+ )
4682def test_extra_withdrawals (
4783 blockchain_test : BlockchainTestFiller ,
4884 pre : Alloc ,
49- # requests_list: List[WithdrawalRequest],
85+ requests_list : List [WithdrawalRequest ],
5086):
5187 """Test how clients were to behave when more than 16 withdrawals would be allowed per block."""
5288 modified_code : bytes = b"3373fffffffffffffffffffffffffffffffffffffffe1460cb5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f457600182026001905f5b5f82111560685781019083028483029004916001019190604d565b909390049250505036603814608857366101f457346101f4575f5260205ff35b34106101f457600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060121160df575060125b5f5b8181146101835782810160030260040181604c02815460601b8152601401816001015481526020019060020154807fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252906010019060401c908160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160e1565b910180921461019557906002556101a0565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101cd57505f5b6001546002828201116101e25750505f6101e8565b01600290035b5f555f600155604c025ff35b5f5ffd" # noqa: E501
@@ -56,20 +92,6 @@ def test_extra_withdrawals(
5692 balance = 0 ,
5793 )
5894
59- # TODO: when i replace the following list with the parameterized version nothing works, why?
60- requests_list : List [WithdrawalRequest ] = [
61- WithdrawalRequest (
62- validator_pubkey = 0x01 ,
63- amount = 0 ,
64- fee = Spec_EIP7002 .get_fee (0 ),
65- ),
66- WithdrawalRequest (
67- validator_pubkey = 0x01 ,
68- amount = 0 ,
69- fee = Spec_EIP7002 .get_fee (0 ),
70- ),
71- ]
72-
7395 # given a list of withdrawal requests construct a withdrawal request transaction
7496 withdrawal_request_transaction = WithdrawalRequestTransaction (requests = requests_list )
7597 # prepare withdrawal senders
@@ -82,8 +104,7 @@ def test_extra_withdrawals(
82104 blocks = [
83105 Block (
84106 txs = txs ,
85- # TODO: why do i have to put the first element here to avoid an error? there is more than 1 request per block # noqa: E501
86- requests_hash = Requests (requests_list [0 ]),
107+ requests_hash = Requests (* requests_list ),
87108 ),
88109 ],
89110 post = {},
0 commit comments