1
1
"""
2
- abstract: Tests get blobs engine endpoint for [EIP-4844: Shard Blob Transactions ](https://eips.ethereum.org/EIPS/eip-4844 )
3
- Test get blobs engine endpoint for [EIP-4844: Shard Blob Transactions ](https://eips.ethereum.org/EIPS/eip-4844 ).
2
+ abstract: Tests get blobs engine endpoint for [EIP-7594: PeerDAS - Peer Data Availability Sampling ](https://eips.ethereum.org/EIPS/eip-7594 )
3
+ Test get blobs engine endpoint for [EIP-7594: PeerDAS - Peer Data Availability Sampling ](https://eips.ethereum.org/EIPS/eip-7594 ).
4
4
5
5
""" # noqa: E501
6
6
7
7
from typing import List , Optional
8
8
9
9
import pytest
10
+ from hive .client import ClientType
10
11
11
- from ethereum_test_forks import Fork
12
+ from ethereum_test_forks import Fork , Osaka
12
13
from ethereum_test_tools import (
13
14
Address ,
14
15
Alloc ,
@@ -137,25 +138,20 @@ def tx_max_fee_per_blob_gas( # noqa: D103
137
138
return blob_gas_price
138
139
139
140
140
- @pytest .fixture
141
- def tx_error () -> Optional [TransactionException ]:
142
- """
143
- Even though the final block we are producing in each of these tests is invalid, and some of the
144
- transactions will be invalid due to the format in the final block, none of the transactions
145
- should be rejected by the transition tool because they are being sent to it with the correct
146
- format.
147
- """
148
- return None
149
-
150
-
151
141
@pytest .fixture
152
142
def tx_wrapper_version () -> int | None :
153
143
"""Return wrapper version used for the transactions sent during test."""
154
144
return 1
155
145
156
146
147
+ @pytest .fixture
148
+ def txs_blobs (test_case_id ) -> List [List [Blob ]]:
149
+ """Extract blobs from the resolved test case."""
150
+ return test_case_id .values [0 ]
151
+
152
+
157
153
@pytest .fixture (autouse = True )
158
- def txs ( # noqa: D103
154
+ def txs (
159
155
pre : Alloc ,
160
156
destination_account : Optional [Address ],
161
157
tx_gas : int ,
@@ -193,15 +189,26 @@ def txs( # noqa: D103
193
189
return txs
194
190
195
191
192
+ def get_max_blobs_per_tx (fork : Fork , client_type : Optional [ClientType ] = None ) -> int :
193
+ """Get max blobs per tx considering both fork and client."""
194
+ # https://github.com/ethereum/go-ethereum/issues/31792
195
+ # https://github.com/ethereum/go-ethereum/pull/31837
196
+ if client_type and "go-ethereum" in client_type .name and fork >= Osaka :
197
+ return 7
198
+ return fork .max_blobs_per_block ()
199
+
200
+
196
201
def generate_full_blob_tests (
197
202
fork : Fork ,
203
+ client_type : Optional [ClientType ] = None ,
198
204
) -> List :
199
205
"""
200
206
Return a list of tests for invalid blob transactions due to insufficient max fee per blob gas
201
207
parametrized for each different fork.
202
208
"""
203
209
blob_size = Spec4844 .FIELD_ELEMENTS_PER_BLOB * SpecHelpers .BYTES_PER_FIELD_ELEMENT
204
- max_blobs = fork .max_blobs_per_block ()
210
+ max_blobs_per_block = fork .max_blobs_per_block ()
211
+ max_blobs_per_tx = get_max_blobs_per_tx (fork , client_type )
205
212
return [
206
213
pytest .param (
207
214
[ # Txs
@@ -223,7 +230,7 @@ def generate_full_blob_tests(
223
230
kzg_commitment = INF_POINT ,
224
231
kzg_cell_proofs = [INF_POINT ] * CELLS_PER_EXT_BLOB ,
225
232
)
226
- for _ in range (max_blobs )
233
+ for _ in range (max_blobs_per_tx )
227
234
]
228
235
],
229
236
id = "max_blobs_transaction" ,
@@ -237,19 +244,38 @@ def generate_full_blob_tests(
237
244
kzg_cell_proofs = [INF_POINT ] * CELLS_PER_EXT_BLOB ,
238
245
)
239
246
]
240
- for _ in range (max_blobs )
247
+ for _ in range (max_blobs_per_block )
241
248
],
242
249
id = "single_blob_max_txs" ,
243
250
),
244
251
]
245
252
246
253
247
- @pytest .mark .parametrize_by_fork (
248
- "txs_blobs" ,
249
- generate_full_blob_tests ,
254
+ @pytest .fixture
255
+ def test_id_matcher (request , fork : Fork , client_type : ClientType ):
256
+ """
257
+ Match test case ID to actual test case for client aware test execution.
258
+ This runs at test execution time when we have access to both the fork and client type.
259
+ """
260
+ requested_id = request .param
261
+ all_test_cases = generate_full_blob_tests (fork , client_type )
262
+ for test_case in all_test_cases :
263
+ if test_case .id == requested_id :
264
+ return test_case
265
+ raise ValueError (f"Test case { requested_id } not found" )
266
+
267
+
268
+ @pytest .mark .parametrize (
269
+ "test_id_matcher" ,
270
+ [
271
+ "single_blob_transaction" ,
272
+ "max_blobs_transaction" ,
273
+ "single_blob_max_txs" ,
274
+ ],
275
+ indirect = True ,
250
276
)
251
- @pytest .mark .exception_test
252
277
@pytest .mark .valid_from ("Cancun" )
278
+ @pytest .mark .exception_test # TODO: should we rename this to not be exception test
253
279
def test_get_blobs (
254
280
blobs_test : BlobsTestFiller ,
255
281
pre : Alloc ,
@@ -259,7 +285,4 @@ def test_get_blobs(
259
285
Test valid blob combinations where one or more txs in the block
260
286
serialized version contain a full blob (network version) tx.
261
287
"""
262
- blobs_test (
263
- pre = pre ,
264
- txs = txs ,
265
- )
288
+ blobs_test (pre = pre , txs = txs )
0 commit comments