1616 is_hex ,
1717 is_integer ,
1818 is_string ,
19+ to_tuple ,
1920)
2021
2122from eth .chains .mainnet import (
@@ -201,7 +202,7 @@ def fixture_transaction_in_rpc_format(state):
201202 }
202203
203204
204- def blockchain_fixture_mark_fn (fixture_path , fixture_name ):
205+ def blockchain_fixture_mark_fn (fixture_path , fixture_name , fixture_fork ):
205206 for slow_test in SLOW_TESTS :
206207 if slow_test in fixture_path or slow_test in fixture_name :
207208 if not should_run_slow_tests ():
@@ -211,13 +212,35 @@ def blockchain_fixture_mark_fn(fixture_path, fixture_name):
211212 return pytest .mark .xfail (reason = "Listed in INCORRECT_UPSTREAM_TESTS." )
212213
213214
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+
214234def pytest_generate_tests (metafunc ):
235+ ignore_fn = generate_ignore_fn_for_fork (metafunc .config .getoption ('fork' ))
215236 generate_fixture_tests (
216237 metafunc = metafunc ,
217238 base_fixture_path = BASE_FIXTURE_PATH ,
239+ preprocess_fn = expand_fixtures_forks ,
218240 filter_fn = filter_fixtures (
219241 fixtures_base_dir = BASE_FIXTURE_PATH ,
220242 mark_fn = blockchain_fixture_mark_fn ,
243+ ignore_fn = ignore_fn
221244 ),
222245 )
223246
@@ -398,8 +421,9 @@ async def validate_uncles(rpc, block_fixture, at_block):
398421
399422@pytest .fixture
400423def 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' :
403427 pytest .skip ('Istanbul VM rules not yet supported' )
404428 return fixture
405429
0 commit comments