16
16
is_hex ,
17
17
is_integer ,
18
18
is_string ,
19
+ to_tuple ,
19
20
)
20
21
21
22
from eth .chains .base import (
@@ -204,7 +205,7 @@ def fixture_transaction_in_rpc_format(state):
204
205
}
205
206
206
207
207
- def blockchain_fixture_mark_fn (fixture_path , fixture_name ):
208
+ def blockchain_fixture_mark_fn (fixture_path , fixture_name , fixture_fork ):
208
209
for slow_test in SLOW_TESTS :
209
210
if slow_test in fixture_path or slow_test in fixture_name :
210
211
if not should_run_slow_tests ():
@@ -214,13 +215,35 @@ def blockchain_fixture_mark_fn(fixture_path, fixture_name):
214
215
return pytest .mark .xfail (reason = "Listed in INCORRECT_UPSTREAM_TESTS." )
215
216
216
217
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
+
217
237
def pytest_generate_tests (metafunc ):
238
+ ignore_fn = generate_ignore_fn_for_fork (metafunc .config .getoption ('fork' ))
218
239
generate_fixture_tests (
219
240
metafunc = metafunc ,
220
241
base_fixture_path = BASE_FIXTURE_PATH ,
242
+ preprocess_fn = expand_fixtures_forks ,
221
243
filter_fn = filter_fixtures (
222
244
fixtures_base_dir = BASE_FIXTURE_PATH ,
223
245
mark_fn = blockchain_fixture_mark_fn ,
246
+ ignore_fn = ignore_fn
224
247
),
225
248
)
226
249
@@ -401,8 +424,9 @@ async def validate_uncles(rpc, block_fixture, at_block):
401
424
402
425
@pytest .fixture
403
426
def 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' :
406
430
pytest .skip ('Istanbul VM rules not yet supported' )
407
431
return fixture
408
432
0 commit comments