16
16
is_hex ,
17
17
is_integer ,
18
18
is_string ,
19
+ to_tuple ,
19
20
)
20
21
21
22
from eth .chains .mainnet import (
@@ -201,7 +202,7 @@ def fixture_transaction_in_rpc_format(state):
201
202
}
202
203
203
204
204
- def blockchain_fixture_mark_fn (fixture_path , fixture_name ):
205
+ def blockchain_fixture_mark_fn (fixture_path , fixture_name , fixture_fork ):
205
206
for slow_test in SLOW_TESTS :
206
207
if slow_test in fixture_path or slow_test in fixture_name :
207
208
if not should_run_slow_tests ():
@@ -211,13 +212,35 @@ def blockchain_fixture_mark_fn(fixture_path, fixture_name):
211
212
return pytest .mark .xfail (reason = "Listed in INCORRECT_UPSTREAM_TESTS." )
212
213
213
214
215
+ # TODO: import from `py-evm` if possible?..
216
+ def generate_ignore_fn_for_fork (passed_fork ):
217
+ if passed_fork :
218
+ passed_fork = passed_fork .lower ()
219
+
220
+ def ignore_fn (fixture_path , fixture_key , fixture_fork ):
221
+ return fixture_fork .lower () != passed_fork
222
+
223
+ return ignore_fn
224
+
225
+
226
+ # TODO: import from `py-evm` if possible?..
227
+ @to_tuple
228
+ def expand_fixtures_forks (all_fixtures ):
229
+ for fixture_path , fixture_key in all_fixtures :
230
+ fixture = load_fixture (fixture_path , fixture_key )
231
+ yield fixture_path , fixture_key , fixture ['network' ]
232
+
233
+
214
234
def pytest_generate_tests (metafunc ):
235
+ ignore_fn = generate_ignore_fn_for_fork (metafunc .config .getoption ('fork' ))
215
236
generate_fixture_tests (
216
237
metafunc = metafunc ,
217
238
base_fixture_path = BASE_FIXTURE_PATH ,
239
+ preprocess_fn = expand_fixtures_forks ,
218
240
filter_fn = filter_fixtures (
219
241
fixtures_base_dir = BASE_FIXTURE_PATH ,
220
242
mark_fn = blockchain_fixture_mark_fn ,
243
+ ignore_fn = ignore_fn
221
244
),
222
245
)
223
246
@@ -398,8 +421,9 @@ async def validate_uncles(rpc, block_fixture, at_block):
398
421
399
422
@pytest .fixture
400
423
def chain_fixture (fixture_data ):
401
- fixture = load_fixture (* fixture_data )
402
- if fixture ['network' ] == 'Istanbul' :
424
+ fixture_path , fixture_key , fixture_fork = fixture_data
425
+ fixture = load_fixture (fixture_path , fixture_key )
426
+ if fixture_fork == 'Istanbul' :
403
427
pytest .skip ('Istanbul VM rules not yet supported' )
404
428
return fixture
405
429
0 commit comments