Skip to content

Commit 77b36d1

Browse files
committed
fix(tests): Requests tests
1 parent bf902b8 commit 77b36d1

File tree

6 files changed

+69
-17
lines changed

6 files changed

+69
-17
lines changed

tests/prague/eip6110_deposits/conftest.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import pytest
77

8-
from ethereum_test_tools import Alloc, Block, BlockException, Header, Transaction
8+
from ethereum_test_forks import Fork
9+
from ethereum_test_tools import Alloc, Block, BlockException, Header, Requests, Transaction
910

1011
from .helpers import DepositInteractionBase, DepositRequest
1112

@@ -61,6 +62,7 @@ def included_requests(
6162

6263
@pytest.fixture
6364
def blocks(
65+
fork: Fork,
6466
included_requests: List[DepositRequest],
6567
block_body_override_requests: List[DepositRequest] | None,
6668
txs: List[Transaction],
@@ -71,9 +73,17 @@ def blocks(
7173
Block(
7274
txs=txs,
7375
header_verify=Header(
74-
requests_hash=included_requests,
76+
requests_hash=Requests(
77+
*included_requests,
78+
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
79+
),
7580
),
76-
requests=block_body_override_requests,
81+
requests=Requests(
82+
*block_body_override_requests,
83+
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
84+
).requests_list
85+
if block_body_override_requests
86+
else None,
7787
exception=exception,
7888
)
7989
]

tests/prague/eip7002_el_triggerable_withdrawals/conftest.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import pytest
88

9-
from ethereum_test_tools import Alloc, Block, Header
9+
from ethereum_test_forks import Fork
10+
from ethereum_test_tools import Alloc, Block, Header, Requests
1011

1112
from .helpers import WithdrawalRequest, WithdrawalRequestInteractionBase
1213
from .spec import Spec
@@ -70,6 +71,7 @@ def included_requests(
7071

7172
@pytest.fixture
7273
def blocks(
74+
fork: Fork,
7375
update_pre: None, # Fixture is used for its side effects
7476
blocks_withdrawal_requests: List[List[WithdrawalRequestInteractionBase]],
7577
included_requests: List[List[WithdrawalRequest]],
@@ -80,13 +82,24 @@ def blocks(
8082
return [ # type: ignore
8183
Block(
8284
txs=sum((r.transactions() for r in block_requests), []),
83-
header_verify=Header(requests_hash=block_included_requests),
85+
header_verify=Header(
86+
requests_hash=Requests(
87+
*block_included_requests,
88+
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
89+
)
90+
),
8491
)
8592
for block_requests, block_included_requests in zip_longest(
8693
blocks_withdrawal_requests,
8794
included_requests,
8895
fillvalue=[],
8996
)
9097
] + [
91-
Block(header_verify=Header(requests_hash=[]))
98+
Block(
99+
header_verify=Header(
100+
requests_hash=Requests(
101+
max_request_type=fork.max_request_type(block_number=1, timestamp=1)
102+
)
103+
)
104+
)
92105
] # Add an empty block at the end to verify that no more withdrawal requests are included

tests/prague/eip7251_consolidations/conftest.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import pytest
88

9-
from ethereum_test_tools import Alloc, Block, Header
9+
from ethereum_test_forks import Fork
10+
from ethereum_test_tools import Alloc, Block, Header, Requests
1011

1112
from .helpers import ConsolidationRequest, ConsolidationRequestInteractionBase
1213
from .spec import Spec
@@ -71,6 +72,7 @@ def included_requests(
7172

7273
@pytest.fixture
7374
def blocks(
75+
fork: Fork,
7476
update_pre: None, # Fixture is used for its side effects
7577
blocks_consolidation_requests: List[List[ConsolidationRequestInteractionBase]],
7678
included_requests: List[List[ConsolidationRequest]],
@@ -81,13 +83,24 @@ def blocks(
8183
return [ # type: ignore
8284
Block(
8385
txs=sum((r.transactions() for r in block_requests), []),
84-
header_verify=Header(requests_hash=block_included_requests),
86+
header_verify=Header(
87+
requests_hash=Requests(
88+
*block_included_requests,
89+
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
90+
)
91+
),
8592
)
8693
for block_requests, block_included_requests in zip_longest(
8794
blocks_consolidation_requests,
8895
included_requests,
8996
fillvalue=[],
9097
)
9198
] + [
92-
Block(header_verify=Header(requests_hash=[]))
99+
Block(
100+
header_verify=Header(
101+
requests_hash=Requests(
102+
max_request_type=fork.max_request_type(block_number=1, timestamp=1)
103+
)
104+
)
105+
)
93106
] # Add an empty block at the end to verify that no more consolidation requests are included

tests/prague/eip7685_general_purpose_el_requests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import pytest
88

9-
from ethereum_test_tools import Alloc, Block, BlockException, Header
9+
from ethereum_test_forks import Fork
10+
from ethereum_test_tools import Alloc, Block, BlockException, Header, Requests
1011

1112
from ..eip6110_deposits.helpers import DepositInteractionBase, DepositRequest
1213
from ..eip7002_el_triggerable_withdrawals.helpers import (
@@ -41,12 +42,14 @@ def exception() -> BlockException | None:
4142

4243
@pytest.fixture
4344
def blocks(
45+
fork: Fork,
4446
pre: Alloc,
4547
requests: List[
4648
DepositInteractionBase
4749
| WithdrawalRequestInteractionBase
4850
| ConsolidationRequestInteractionBase
4951
],
52+
# TODO: Not as easy as the other EIPs to refactor
5053
block_body_override_requests: List[
5154
DepositRequest | WithdrawalRequest | ConsolidationRequest | SupportsBytes
5255
]
@@ -78,7 +81,10 @@ def blocks(
7881
Block(
7982
txs=sum((r.transactions() for r in requests), []),
8083
header_verify=Header(
81-
requests_hash=valid_requests,
84+
requests_hash=Requests(
85+
*valid_requests,
86+
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
87+
),
8288
),
8389
requests=block_body_override_requests,
8490
exception=exception,

tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import pytest
1111

12+
from ethereum_test_forks import Fork
1213
from ethereum_test_tools import (
1314
Account,
1415
Address,
@@ -21,7 +22,7 @@
2122
Header,
2223
)
2324
from ethereum_test_tools import Opcodes as Op
24-
from ethereum_test_tools import Storage, TestAddress, TestAddress2, Transaction
25+
from ethereum_test_tools import Requests, Storage, TestAddress, TestAddress2, Transaction
2526

2627
from ..eip6110_deposits.helpers import DepositContract, DepositRequest, DepositTransaction
2728
from ..eip6110_deposits.spec import Spec as Spec_EIP6110
@@ -239,6 +240,7 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
239240
blockchain_test: BlockchainTestFiller,
240241
pre: Alloc,
241242
requests: List[DepositRequest | WithdrawalRequest | ConsolidationRequest],
243+
fork: Fork,
242244
):
243245
"""
244246
Test making a deposit to the beacon chain deposit contract and a withdrawal in the same tx.
@@ -307,10 +309,13 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
307309
Block(
308310
txs=[tx],
309311
header_verify=Header(
310-
requests_hash=[
311-
request.with_source_address(contract_address)
312-
for request in sorted(requests, key=lambda r: r.type_byte)
313-
]
312+
requests_hash=Requests(
313+
*[
314+
request.with_source_address(contract_address)
315+
for request in sorted(requests, key=lambda r: r.type)
316+
],
317+
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
318+
)
314319
),
315320
)
316321
],

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212

1313
from ethereum_test_addresses import SystemContract
14+
from ethereum_test_forks import Fork
1415
from ethereum_test_tools import (
1516
AccessList,
1617
Account,
@@ -31,6 +32,7 @@
3132
from ethereum_test_tools import Macros as Om
3233
from ethereum_test_tools import Opcodes as Op
3334
from ethereum_test_tools import (
35+
Requests,
3436
StateTestFiller,
3537
Storage,
3638
Transaction,
@@ -2422,6 +2424,7 @@ def deposit_contract_initial_storage() -> Storage:
24222424
def test_set_code_to_system_contract(
24232425
blockchain_test: BlockchainTestFiller,
24242426
pre: Alloc,
2427+
fork: Fork,
24252428
system_contract: int,
24262429
call_opcode: Op,
24272430
):
@@ -2527,7 +2530,9 @@ def test_set_code_to_system_contract(
25272530
blocks=[
25282531
Block(
25292532
txs=txs,
2530-
requests_hash=[], # Verify nothing slipped into the requests trie
2533+
requests_hash=Requests(
2534+
max_request_type=fork.max_request_type(block_number=1)
2535+
), # Verify nothing slipped into the requests trie
25312536
)
25322537
],
25332538
post={

0 commit comments

Comments
 (0)