Skip to content

Commit 5253387

Browse files
committed
update tests to align with mutation testing
1 parent c612d3d commit 5253387

29 files changed

+904
-60
lines changed

tests/berlin/test_evm_tools.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@
2424
"loopMul",
2525
)
2626

27+
# angry mutant cases are tests that cannot be run for mutation testing
28+
ANGRY_MUTANT_CASES = (
29+
"Callcode1024OOG",
30+
"Call1024OOG",
31+
"CallRecursiveBombPreCall",
32+
"CallRecursiveBombLog2",
33+
"CallRecursiveBomb2",
34+
"ABAcalls1",
35+
"CallRecursiveBomb0_OOG_atMaxCallDepth",
36+
"ABAcalls2",
37+
"CallRecursiveBomb0",
38+
"CallRecursiveBomb1",
39+
"CallRecursiveBombLog"
40+
)
41+
2742

2843
# Define tests
2944
fetch_tests = partial(
@@ -37,23 +52,37 @@
3752
fork_name=FORK_NAME,
3853
)
3954

55+
def is_angry_mutant(test_case):
56+
return any(case in str(test_case) for case in ANGRY_MUTANT_CASES)
57+
58+
59+
ethereum_state_test_cases = [
60+
pytest.param(tc, marks=pytest.mark.angry_mutant)
61+
if is_angry_mutant(tc)
62+
else tc
63+
for tc in fetch_tests(ETHEREUM_STATE_TESTS_DIR)
64+
]
65+
4066

4167
# Run tests from ethereum/tests
4268
@pytest.mark.evm_tools
4369
@pytest.mark.parametrize(
4470
"test_case",
45-
fetch_tests(ETHEREUM_STATE_TESTS_DIR),
71+
ethereum_state_test_cases,
4672
ids=idfn,
4773
)
4874
def test_ethereum_tests_evm_tools(test_case: Dict) -> None:
4975
run_tests(test_case)
5076

5177

78+
eest_state_test_cases = list(fetch_tests(EEST_STATE_TESTS_DIR))
79+
80+
5281
# Run EEST test fixtures
5382
@pytest.mark.evm_tools
5483
@pytest.mark.parametrize(
5584
"test_case",
56-
fetch_tests(EEST_STATE_TESTS_DIR),
85+
eest_state_test_cases,
5786
ids=idfn,
5887
)
5988
def test_eest_evm_tools(test_case: Dict) -> None:

tests/berlin/test_state_transition.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@
6262
"stTimeConsuming/",
6363
)
6464

65+
# angry mutant cases are tests that cannot be run for mutation testing
66+
ANGRY_MUTANT_CASES = (
67+
"Callcode1024OOG",
68+
"Call1024OOG",
69+
"CallRecursiveBombPreCall",
70+
"CallRecursiveBomb1",
71+
"ABAcalls2",
72+
"CallRecursiveBombLog2",
73+
"CallRecursiveBomb0",
74+
"ABAcalls1",
75+
"CallRecursiveBomb2",
76+
"CallRecursiveBombLog"
77+
)
78+
6579
# Define Tests
6680
fetch_tests = partial(
6781
fetch_state_test_files,
@@ -76,20 +90,36 @@
7690
run_tests = partial(run_blockchain_st_test, load=FIXTURES_LOADER)
7791

7892

93+
def is_angry_mutant(test_case):
94+
return any(case in str(test_case) for case in ANGRY_MUTANT_CASES)
95+
96+
97+
# Run tests from ethereum/tests
98+
ethereum_blockchain_test_cases = [
99+
pytest.param(tc, marks=pytest.mark.angry_mutant)
100+
if is_angry_mutant(tc)
101+
else tc
102+
for tc in fetch_tests(ETHEREUM_BLOCKCHAIN_TESTS_DIR)
103+
]
104+
105+
79106
# Run tests from ethereum/tests
80107
@pytest.mark.parametrize(
81108
"test_case",
82-
fetch_tests(ETHEREUM_BLOCKCHAIN_TESTS_DIR),
109+
ethereum_blockchain_test_cases,
83110
ids=idfn,
84111
)
85112
def test_ethereum_tests(test_case: Dict) -> None:
86113
run_tests(test_case)
87114

88115

116+
eest_test_cases = list(fetch_tests(EEST_BLOCKCHAIN_TESTS_DIR))
117+
118+
89119
# Run EEST test fixtures
90120
@pytest.mark.parametrize(
91121
"test_case",
92-
fetch_tests(EEST_BLOCKCHAIN_TESTS_DIR),
122+
eest_test_cases,
93123
ids=idfn,
94124
)
95125
def test_eest_tests(test_case: Dict) -> None:

tests/byzantium/test_evm_tools.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818

1919
SLOW_TESTS = ()
2020

21+
# angry mutant cases are tests that cannot be run for mutation testing
22+
ANGRY_MUTANT_CASES = (
23+
"Callcode1024OOG",
24+
"Call1024OOG",
25+
"CallRecursiveBombPreCall",
26+
"CallRecursiveBombLog2",
27+
"CallRecursiveBomb2",
28+
"ABAcalls1",
29+
"CallRecursiveBomb0_OOG_atMaxCallDepth",
30+
"ABAcalls2",
31+
"CallRecursiveBomb0",
32+
"CallRecursiveBomb1",
33+
"CallRecursiveBombLog"
34+
)
35+
2136
# Define tests
2237
fetch_tests = partial(
2338
fetch_evm_tools_tests,
@@ -31,22 +46,37 @@
3146
)
3247

3348

49+
def is_angry_mutant(test_case):
50+
return any(case in str(test_case) for case in ANGRY_MUTANT_CASES)
51+
52+
53+
ethereum_state_test_cases = [
54+
pytest.param(tc, marks=pytest.mark.angry_mutant)
55+
if is_angry_mutant(tc)
56+
else tc
57+
for tc in fetch_tests(ETHEREUM_STATE_TESTS_DIR)
58+
]
59+
60+
3461
# Run tests from ethereum/tests
3562
@pytest.mark.evm_tools
3663
@pytest.mark.parametrize(
3764
"test_case",
38-
fetch_tests(ETHEREUM_STATE_TESTS_DIR),
65+
ethereum_state_test_cases,
3966
ids=idfn,
4067
)
4168
def test_ethereum_tests_evm_tools(test_case: Dict) -> None:
4269
run_tests(test_case)
4370

4471

72+
eest_state_test_cases = list(fetch_tests(EEST_STATE_TESTS_DIR))
73+
74+
4575
# Run EEST test fixtures
4676
@pytest.mark.evm_tools
4777
@pytest.mark.parametrize(
4878
"test_case",
49-
fetch_tests(EEST_STATE_TESTS_DIR),
79+
eest_state_test_cases,
5080
ids=idfn,
5181
)
5282
def test_eest_evm_tools(test_case: Dict) -> None:

tests/byzantium/test_state_transition.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@
5656
"bcUncleHeaderValidity/wrongMixHash.json",
5757
)
5858

59+
# angry mutant cases are tests that cannot be run for mutation testing
60+
ANGRY_MUTANT_CASES = (
61+
"Callcode1024OOG",
62+
"Call1024OOG",
63+
"CallRecursiveBombPreCall",
64+
"CallRecursiveBomb1",
65+
"ABAcalls2",
66+
"CallRecursiveBombLog2",
67+
"CallRecursiveBomb0",
68+
"ABAcalls1",
69+
"CallRecursiveBomb2",
70+
"CallRecursiveBombLog"
71+
)
72+
5973
# Define Tests
6074
fetch_tests = partial(
6175
fetch_state_test_files,
@@ -70,20 +84,36 @@
7084
run_tests = partial(run_blockchain_st_test, load=FIXTURES_LOADER)
7185

7286

87+
def is_angry_mutant(test_case):
88+
return any(case in str(test_case) for case in ANGRY_MUTANT_CASES)
89+
90+
91+
# Run tests from ethereum/tests
92+
ethereum_blockchain_test_cases = [
93+
pytest.param(tc, marks=pytest.mark.angry_mutant)
94+
if is_angry_mutant(tc)
95+
else tc
96+
for tc in fetch_tests(ETHEREUM_BLOCKCHAIN_TESTS_DIR)
97+
]
98+
99+
73100
# Run tests from ethereum/tests
74101
@pytest.mark.parametrize(
75102
"test_case",
76-
fetch_tests(ETHEREUM_BLOCKCHAIN_TESTS_DIR),
103+
ethereum_blockchain_test_cases,
77104
ids=idfn,
78105
)
79106
def test_ethereum_tests(test_case: Dict) -> None:
80107
run_tests(test_case)
81108

82109

110+
eest_test_cases = list(fetch_tests(EEST_BLOCKCHAIN_TESTS_DIR))
111+
112+
83113
# Run EEST test fixtures
84114
@pytest.mark.parametrize(
85115
"test_case",
86-
fetch_tests(EEST_BLOCKCHAIN_TESTS_DIR),
116+
eest_test_cases,
87117
ids=idfn,
88118
)
89119
def test_eest_tests(test_case: Dict) -> None:

tests/cancun/test_evm_tools.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
"GeneralStateTests/VMTests/vmPerformance/loopMul.json::loopMul-fork_[Cancun-Prague]-d[0-2]g0v0",
2121
)
2222

23+
# angry mutant cases are tests that cannot be run for mutation testing
24+
ANGRY_MUTANT_CASES = (
25+
"Callcode1024OOG",
26+
"Call1024OOG",
27+
"CallRecursiveBombPreCall",
28+
"CallRecursiveBombLog2",
29+
"CallRecursiveBomb2",
30+
"ABAcalls1",
31+
"CallRecursiveBomb0_OOG_atMaxCallDepth",
32+
"ABAcalls2",
33+
"CallRecursiveBomb0",
34+
"CallRecursiveBomb1",
35+
"CallRecursiveBombLog"
36+
)
2337

2438
# Define tests
2539
fetch_tests = partial(
@@ -34,22 +48,37 @@
3448
)
3549

3650

51+
def is_angry_mutant(test_case):
52+
return any(case in str(test_case) for case in ANGRY_MUTANT_CASES)
53+
54+
55+
ethereum_state_test_cases = [
56+
pytest.param(tc, marks=pytest.mark.angry_mutant)
57+
if is_angry_mutant(tc)
58+
else tc
59+
for tc in fetch_tests(ETHEREUM_STATE_TESTS_DIR)
60+
]
61+
62+
3763
# Run tests from ethereum/tests
3864
@pytest.mark.evm_tools
3965
@pytest.mark.parametrize(
4066
"test_case",
41-
fetch_tests(ETHEREUM_STATE_TESTS_DIR),
67+
ethereum_state_test_cases,
4268
ids=idfn,
4369
)
4470
def test_ethereum_tests_evm_tools(test_case: Dict) -> None:
4571
run_tests(test_case)
4672

4773

74+
eest_state_test_cases = list(fetch_tests(EEST_STATE_TESTS_DIR))
75+
76+
4877
# Run EEST test fixtures
4978
@pytest.mark.evm_tools
5079
@pytest.mark.parametrize(
5180
"test_case",
52-
fetch_tests(EEST_STATE_TESTS_DIR),
81+
eest_state_test_cases,
5382
ids=idfn,
5483
)
5584
def test_eest_evm_tools(test_case: Dict) -> None:

tests/cancun/test_state_transition.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@
6262
"stStaticCall/",
6363
)
6464

65+
# angry mutant cases are tests that cannot be run for mutation testing
66+
ANGRY_MUTANT_CASES = (
67+
"Callcode1024OOG",
68+
"Call1024OOG",
69+
"CallRecursiveBombPreCall",
70+
"CallRecursiveBomb1",
71+
"ABAcalls2",
72+
"CallRecursiveBombLog2",
73+
"CallRecursiveBomb0",
74+
"ABAcalls1",
75+
"CallRecursiveBomb2",
76+
"CallRecursiveBombLog"
77+
)
78+
6579
# Define Tests
6680
fetch_tests = partial(
6781
fetch_state_test_files,
@@ -76,20 +90,36 @@
7690
run_tests = partial(run_blockchain_st_test, load=FIXTURES_LOADER)
7791

7892

93+
def is_angry_mutant(test_case):
94+
return any(case in str(test_case) for case in ANGRY_MUTANT_CASES)
95+
96+
97+
# Run tests from ethereum/tests
98+
ethereum_blockchain_test_cases = [
99+
pytest.param(tc, marks=pytest.mark.angry_mutant)
100+
if is_angry_mutant(tc)
101+
else tc
102+
for tc in fetch_tests(ETHEREUM_BLOCKCHAIN_TESTS_DIR)
103+
]
104+
105+
79106
# Run tests from ethereum/tests
80107
@pytest.mark.parametrize(
81108
"test_case",
82-
fetch_tests(ETHEREUM_BLOCKCHAIN_TESTS_DIR),
109+
ethereum_blockchain_test_cases,
83110
ids=idfn,
84111
)
85112
def test_ethereum_tests(test_case: Dict) -> None:
86113
run_tests(test_case)
87114

88115

116+
eest_test_cases = list(fetch_tests(EEST_BLOCKCHAIN_TESTS_DIR))
117+
118+
89119
# Run EEST test fixtures
90120
@pytest.mark.parametrize(
91121
"test_case",
92-
fetch_tests(EEST_BLOCKCHAIN_TESTS_DIR),
122+
eest_test_cases,
93123
ids=idfn,
94124
)
95125
def test_eest_tests(test_case: Dict) -> None:

tests/conftest.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ def __exit__(
175175

176176

177177
def pytest_sessionstart(session: Session) -> None: # noqa: U100
178+
# used for mutmut mutation testing
179+
all_fixtures_ready = all(
180+
os.path.exists(props["fixture_path"])
181+
for props in TEST_FIXTURES.values()
182+
)
183+
if os.environ.get("MUTANT_UNDER_TEST") and all_fixtures_ready:
184+
return
185+
178186
if get_xdist_worker_id(session) != "master":
179187
return
180188

@@ -210,8 +218,9 @@ def pytest_sessionfinish(
210218
if get_xdist_worker_id(session) != "master":
211219
return
212220

213-
lock_file = session.stash[fixture_lock]
214-
session.stash[fixture_lock] = None
221+
if fixture_lock in session.stash:
222+
lock_file = session.stash[fixture_lock]
223+
session.stash[fixture_lock] = None
215224

216-
assert lock_file is not None
217-
lock_file.release()
225+
assert lock_file is not None
226+
lock_file.release()

0 commit comments

Comments
 (0)