1616 is_hex ,
1717 is_integer ,
1818 is_string ,
19+ to_tuple ,
1920)
2021
2122from eth .chains .base import (
@@ -204,7 +205,7 @@ def fixture_transaction_in_rpc_format(state):
204205 }
205206
206207
207- def blockchain_fixture_mark_fn (fixture_path , fixture_name ):
208+ def blockchain_fixture_mark_fn (fixture_path , fixture_name , fixture_fork ):
208209 for slow_test in SLOW_TESTS :
209210 if slow_test in fixture_path or slow_test in fixture_name :
210211 if not should_run_slow_tests ():
@@ -214,13 +215,35 @@ def blockchain_fixture_mark_fn(fixture_path, fixture_name):
214215 return pytest .mark .xfail (reason = "Listed in INCORRECT_UPSTREAM_TESTS." )
215216
216217
218+ # TODO: import from `py-evm` if possible?..
219+ def generate_ignore_fn_for_fork (passed_fork ):
220+ if passed_fork :
221+ passed_fork = passed_fork .lower ()
222+
223+ def ignore_fn (fixture_path , fixture_key , fixture_fork ):
224+ return fixture_fork .lower () != passed_fork
225+
226+ return ignore_fn
227+
228+
229+ # TODO: import from `py-evm` if possible?..
230+ @to_tuple
231+ def expand_fixtures_forks (all_fixtures ):
232+ for fixture_path , fixture_key in all_fixtures :
233+ fixture = load_fixture (fixture_path , fixture_key )
234+ yield fixture_path , fixture_key , fixture ['network' ]
235+
236+
217237def pytest_generate_tests (metafunc ):
238+ ignore_fn = generate_ignore_fn_for_fork (metafunc .config .getoption ('fork' ))
218239 generate_fixture_tests (
219240 metafunc = metafunc ,
220241 base_fixture_path = BASE_FIXTURE_PATH ,
242+ preprocess_fn = expand_fixtures_forks ,
221243 filter_fn = filter_fixtures (
222244 fixtures_base_dir = BASE_FIXTURE_PATH ,
223245 mark_fn = blockchain_fixture_mark_fn ,
246+ ignore_fn = ignore_fn
224247 ),
225248 )
226249
@@ -401,8 +424,9 @@ async def validate_uncles(rpc, block_fixture, at_block):
401424
402425@pytest .fixture
403426def chain_fixture (fixture_data ):
404- fixture = load_fixture (* fixture_data )
405- if fixture ['network' ] == 'Istanbul' :
427+ fixture_path , fixture_key , fixture_fork = fixture_data
428+ fixture = load_fixture (fixture_path , fixture_key )
429+ if fixture_fork == 'Istanbul' :
406430 pytest .skip ('Istanbul VM rules not yet supported' )
407431 return fixture
408432
0 commit comments