1
- from typing import Tuple
1
+ import re
2
+ from dataclasses import dataclass
3
+ from typing import Pattern , Tuple
2
4
3
5
4
- def get_exceptional_blockchain_test_patterns (
6
+ @dataclass
7
+ class TestPatterns :
8
+ """
9
+ Identify test patterns which are slow, are to be ignored
10
+ or are to be marked as consuming large memory at runtime.
11
+ """
12
+
13
+ slow : Tuple [Pattern [str ], ...]
14
+ expected_fail : Tuple [Pattern [str ], ...]
15
+ big_memory : Tuple [Pattern [str ], ...]
16
+
17
+
18
+ def exceptional_blockchain_test_patterns (
5
19
json_fork : str , eels_fork : str
6
- ) -> Tuple [ tuple [ str , ...], tuple [ str , ...], tuple [ str , ...]] :
20
+ ) -> TestPatterns :
7
21
"""
8
22
Returns patterns for slow, ignored, and big-memory tests for a given json_fork and eels_fork.
9
23
@@ -16,21 +30,20 @@ def get_exceptional_blockchain_test_patterns(
16
30
17
31
Returns
18
32
-------
19
- slow_tests :
20
- Patterns to match test files or test ids that should be marked as slow.
21
- ignore_tests :
22
- Patterns to match test files or test ids that should be ignored.
23
- big_memory_tests :
24
- Patterns to match test files or test ids that require large memory.
33
+ TestPatterns :
34
+ Patterns that are relevant to the current fork.
25
35
"""
36
+ jf = re .escape (json_fork )
37
+ ef = re .escape (eels_fork )
38
+
26
39
slow_tests = (
27
40
# GeneralStateTests
28
41
"stTimeConsuming/CALLBlake2f_MaxRounds.json" ,
29
42
"stTimeConsuming/static_Call50000_sha256.json" ,
30
43
"vmPerformance/loopExp.json" ,
31
44
"vmPerformance/loopMul.json" ,
32
- f"QuadraticComplexitySolidity_CallDataCopy_d0g1v0_{ json_fork } " ,
33
- f"CALLBlake2f_d9g0v0_{ json_fork } " ,
45
+ f"QuadraticComplexitySolidity_CallDataCopy_d0g1v0_{ jf } " ,
46
+ f"CALLBlake2f_d9g0v0_{ jf } " ,
34
47
"CALLCODEBlake2f_d9g0v0" ,
35
48
# GeneralStateTests
36
49
"stRandom/randomStatetest177.json" ,
@@ -40,19 +53,19 @@ def get_exceptional_blockchain_test_patterns(
40
53
# InvalidBlockTest
41
54
"bcUncleHeaderValidity/nonceWrong.json" ,
42
55
"bcUncleHeaderValidity/wrongMixHash.json" ,
43
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing\\ .py\\ : \\ :test_valid\\ [fork_{ json_fork } -blockchain_test-bls_pairing_non-degeneracy-\\ ]" ,
44
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing\\ .py\\ : \\ :test_valid\\ [fork_{ json_fork } -blockchain_test-bls_pairing_bilinearity-\\ ]" ,
45
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing\\ .py\\ : \\ :test_valid\\ [fork_{ json_fork } -blockchain_test-bls_pairing_e\\ (G1,-G2\\ )=e\\ (-G1,G2\\ )-\\ ]" ,
46
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing\\ .py\\ : \\ :test_valid\\ [fork_{ json_fork } -blockchain_test-bls_pairing_e\\ (aG1,bG2\\ )=e\\ (abG1,G2\\ )-\\ ]" ,
47
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing\\ .py\\ : \\ :test_valid\\ [fork_{ json_fork } -blockchain_test-bls_pairing_e\\ (aG1,bG2\\ )=e\\ (G1,abG2\\ )-\\ ]" ,
48
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing\\ .py\\ : \\ :test_valid\\ [fork_{ json_fork } -blockchain_test-inf_pair-\\ ]" ,
49
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing\\ .py\\ : \\ :test_valid\\ [fork_{ json_fork } -blockchain_test-multi_inf_pair-\\ ]" ,
50
- f"tests/{ eels_fork } /eip2935_historical_block_hashes_from_state/test_block_hashes\\ .py\\ : \\ :test_block_hashes_history\\ [fork_{ json_fork } -blockchain_test-full_history_plus_one_check_blockhash_first\\ ]" ,
56
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py: :test_valid\\ [fork_{ jf } -blockchain_test-bls_pairing_non-degeneracy-\\ ]" ,
57
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py: :test_valid\\ [fork_{ jf } -blockchain_test-bls_pairing_bilinearity-\\ ]" ,
58
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py: :test_valid\\ [fork_{ jf } -blockchain_test-bls_pairing_e(G1,-G2)=e(-G1,G2)-\\ ]" ,
59
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py: :test_valid\\ [fork_{ jf } -blockchain_test-bls_pairing_e(aG1,bG2)=e(abG1,G2)-\\ ]" ,
60
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py: :test_valid\\ [fork_{ jf } -blockchain_test-bls_pairing_e(aG1,bG2)=e(G1,abG2)-\\ ]" ,
61
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py: :test_valid\\ [fork_{ jf } -blockchain_test-inf_pair-\\ ]" ,
62
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py: :test_valid\\ [fork_{ jf } -blockchain_test-multi_inf_pair-\\ ]" ,
63
+ f"tests/{ ef } /eip2935_historical_block_hashes_from_state/test_block_hashes.py: :test_block_hashes_history\\ [fork_{ jf } -blockchain_test-full_history_plus_one_check_blockhash_first\\ ]" ,
51
64
)
52
65
53
66
# These are tests that are considered to be incorrect,
54
67
# Please provide an explanation when adding entries
55
- ignore_tests = (
68
+ expected_fail = (
56
69
# ValidBlockTest
57
70
"bcForkStressTest/ForkStressTest.json" ,
58
71
"bcGasPricerTest/RPC_API_Test.json" ,
@@ -61,7 +74,7 @@ def get_exceptional_blockchain_test_patterns(
61
74
# InvalidBlockTest
62
75
"bcForgedTest" ,
63
76
"bcMultiChainTest" ,
64
- f"GasLimitHigherThan2p63m1_{ json_fork } " ,
77
+ f"GasLimitHigherThan2p63m1_{ jf } " ,
65
78
)
66
79
67
80
# All tests that recursively create a large number of frames (50000)
@@ -77,28 +90,38 @@ def get_exceptional_blockchain_test_patterns(
77
90
"stStaticCall/" ,
78
91
)
79
92
80
- return slow_tests , ignore_tests , big_memory_tests
93
+ return TestPatterns (
94
+ slow = tuple (re .compile (p ) for p in slow_tests ),
95
+ expected_fail = tuple (re .compile (p ) for p in expected_fail ),
96
+ big_memory = tuple (re .compile (p ) for p in big_memory_tests ),
97
+ )
81
98
82
99
83
- def get_exceptional_state_test_patterns (
100
+ def exceptional_state_test_patterns (
84
101
json_fork : str , eels_fork : str
85
- ) -> tuple [str , ...]:
102
+ ) -> TestPatterns :
103
+ jf = re .escape (json_fork )
104
+ ef = re .escape (eels_fork )
86
105
slow_tests = (
87
106
"CALLBlake2f_MaxRounds" ,
88
107
"CALLCODEBlake2f" ,
89
108
"CALLBlake2f" ,
90
109
"loopExp" ,
91
110
"loopMul" ,
92
- "GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json::CALLBlake2f_MaxRounds-fork_[Cancun-Prague]-d0g0v0" ,
93
- "GeneralStateTests/VMTests/vmPerformance/loopExp.json::loopExp-fork_[Cancun-Prague]-d[0-14]g0v0" ,
94
- "GeneralStateTests/VMTests/vmPerformance/loopMul.json::loopMul-fork_[Cancun-Prague]-d[0-2]g0v0" ,
95
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{ json_fork } -state_test-bls_pairing_non-degeneracy-]" ,
96
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{ json_fork } -state_test-bls_pairing_bilinearity-]" ,
97
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{ json_fork } -state_test-bls_pairing_e(G1,-G2)=e(-G1,G2)-]" ,
98
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{ json_fork } -state_test-bls_pairing_e(aG1,bG2)=e(abG1,G2)-]" ,
99
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{ json_fork } -state_test-bls_pairing_e(aG1,bG2)=e(G1,abG2)-]" ,
100
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{ json_fork } -state_test-inf_pair-]" ,
101
- f"tests/{ eels_fork } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{ json_fork } -state_test-multi_inf_pair-]" ,
111
+ "GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json::CALLBlake2f_MaxRounds-fork_\\ [Cancun-Prague\\ ]-d0g0v0" ,
112
+ "GeneralStateTests/VMTests/vmPerformance/loopExp.json::loopExp-fork_\\ [Cancun-Prague\\ ]-d[0-14]g0v0" ,
113
+ "GeneralStateTests/VMTests/vmPerformance/loopMul.json::loopMul-fork_\\ [Cancun-Prague\\ ]-d[0-2]g0v0" ,
114
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid\\ [fork_{ jf } -state_test-bls_pairing_non-degeneracy-\\ ]" ,
115
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid\\ [fork_{ jf } -state_test-bls_pairing_bilinearity-\\ ]" ,
116
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid\\ [fork_{ jf } -state_test-bls_pairing_e(G1,-G2)=e(-G1,G2)-\\ ]" ,
117
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid\\ [fork_{ jf } -state_test-bls_pairing_e(aG1,bG2)=e(abG1,G2)-\\ ]" ,
118
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid\\ [fork_{ jf } -state_test-bls_pairing_e(aG1,bG2)=e(G1,abG2)-\\ ]" ,
119
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid\\ [fork_{ jf } -state_test-inf_pair-\\ ]" ,
120
+ f"tests/{ ef } /eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid\\ [fork_{ jf } -state_test-multi_inf_pair-\\ ]" ,
102
121
)
103
122
104
- return slow_tests
123
+ return TestPatterns (
124
+ slow = tuple (re .compile (p ) for p in slow_tests ),
125
+ expected_fail = tuple (),
126
+ big_memory = tuple (),
127
+ )
0 commit comments