Skip to content

Commit f4da641

Browse files
committed
post review: rename to json_fork and eels_fork
1 parent 7881f92 commit f4da641

File tree

5 files changed

+55
-52
lines changed

5 files changed

+55
-52
lines changed

tests/json_infra/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ def _build_eest_test_paths(base_path: str) -> tuple:
8282
)
8383

8484

85-
def _create_fork_config(package: str, bc_dirs: list, state_dirs: list) -> dict:
85+
def _create_fork_config(
86+
eels_fork: str, bc_dirs: list, state_dirs: list
87+
) -> dict:
8688
return {
87-
"package": package,
89+
"eels_fork": eels_fork,
8890
"blockchain_test_dirs": bc_dirs,
8991
"state_test_dirs": state_dirs,
9092
}
@@ -112,8 +114,8 @@ def _create_fork_config(package: str, bc_dirs: list, state_dirs: list) -> dict:
112114

113115
FORKS = {
114116
**{
115-
fork: _create_fork_config(package, *PRE_CONSTANTINOPLE_DIRS)
116-
for fork, package in [
117+
json_fork: _create_fork_config(eels_fork, *PRE_CONSTANTINOPLE_DIRS)
118+
for json_fork, eels_fork in [
117119
("Frontier", "frontier"),
118120
("Homestead", "homestead"),
119121
("EIP150", "tangerine_whistle"),
@@ -123,8 +125,8 @@ def _create_fork_config(package: str, bc_dirs: list, state_dirs: list) -> dict:
123125
]
124126
},
125127
**{
126-
fork: _create_fork_config(package, *PRE_CANCUN_DIRS)
127-
for fork, package in [
128+
json_fork: _create_fork_config(eels_fork, *PRE_CANCUN_DIRS)
129+
for json_fork, eels_fork in [
128130
("Istanbul", "istanbul"),
129131
("Berlin", "berlin"),
130132
("London", "london"),
@@ -133,8 +135,8 @@ def _create_fork_config(package: str, bc_dirs: list, state_dirs: list) -> dict:
133135
]
134136
},
135137
**{
136-
fork: _create_fork_config(package, *CURRENT_DIRS)
137-
for fork, package in [
138+
json_fork: _create_fork_config(eels_fork, *CURRENT_DIRS)
139+
for json_fork, eels_fork in [
138140
("Cancun", "cancun"),
139141
("Prague", "prague"),
140142
]

tests/json_infra/helpers/exceptional_test_patterns.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33

44
def get_exceptional_blockchain_test_patterns(
5-
network: str, package: str
5+
json_fork: str, eels_fork: str
66
) -> Tuple[tuple[str, ...], tuple[str, ...], tuple[str, ...]]:
77
"""
8-
Returns patterns for slow, ignored, and big-memory tests for a given network and package.
8+
Returns patterns for slow, ignored, and big-memory tests for a given json_fork and eels_fork.
99
1010
Parameters
1111
----------
12-
network : str
13-
The network name (e.g., "Frontier", "EIP150").
14-
package : str
15-
The package name (e.g., "frontier", "tangerine_whistle").
12+
json_fork : str
13+
The json_fork name (e.g., "Frontier", "EIP150").
14+
eels_fork : str
15+
The eels_fork name (e.g., "frontier", "tangerine_whistle").
1616
1717
Returns
1818
-------
@@ -29,8 +29,8 @@ def get_exceptional_blockchain_test_patterns(
2929
"stTimeConsuming/static_Call50000_sha256.json",
3030
"vmPerformance/loopExp.json",
3131
"vmPerformance/loopMul.json",
32-
f"QuadraticComplexitySolidity_CallDataCopy_d0g1v0_{network}",
33-
f"CALLBlake2f_d9g0v0_{network}",
32+
f"QuadraticComplexitySolidity_CallDataCopy_d0g1v0_{json_fork}",
33+
f"CALLBlake2f_d9g0v0_{json_fork}",
3434
"CALLCODEBlake2f_d9g0v0",
3535
# GeneralStateTests
3636
"stRandom/randomStatetest177.json",
@@ -40,14 +40,14 @@ def get_exceptional_blockchain_test_patterns(
4040
# InvalidBlockTest
4141
"bcUncleHeaderValidity/nonceWrong.json",
4242
"bcUncleHeaderValidity/wrongMixHash.json",
43-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing\\.py\\:\\:test_valid\\[fork_{network}-blockchain_test-bls_pairing_non-degeneracy-\\]",
44-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing\\.py\\:\\:test_valid\\[fork_{network}-blockchain_test-bls_pairing_bilinearity-\\]",
45-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing\\.py\\:\\:test_valid\\[fork_{network}-blockchain_test-bls_pairing_e\\(G1,-G2\\)=e\\(-G1,G2\\)-\\]",
46-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing\\.py\\:\\:test_valid\\[fork_{network}-blockchain_test-bls_pairing_e\\(aG1,bG2\\)=e\\(abG1,G2\\)-\\]",
47-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing\\.py\\:\\:test_valid\\[fork_{network}-blockchain_test-bls_pairing_e\\(aG1,bG2\\)=e\\(G1,abG2\\)-\\]",
48-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing\\.py\\:\\:test_valid\\[fork_{network}-blockchain_test-inf_pair-\\]",
49-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing\\.py\\:\\:test_valid\\[fork_{network}-blockchain_test-multi_inf_pair-\\]",
50-
f"tests/{package}/eip2935_historical_block_hashes_from_state/test_block_hashes\\.py\\:\\:test_block_hashes_history\\[fork_{network}-blockchain_test-full_history_plus_one_check_blockhash_first\\]",
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\\]",
5151
)
5252

5353
# These are tests that are considered to be incorrect,
@@ -61,7 +61,7 @@ def get_exceptional_blockchain_test_patterns(
6161
# InvalidBlockTest
6262
"bcForgedTest",
6363
"bcMultiChainTest",
64-
f"GasLimitHigherThan2p63m1_{network}",
64+
f"GasLimitHigherThan2p63m1_{json_fork}",
6565
)
6666

6767
# All tests that recursively create a large number of frames (50000)
@@ -81,7 +81,7 @@ def get_exceptional_blockchain_test_patterns(
8181

8282

8383
def get_exceptional_state_test_patterns(
84-
network: str, package: str
84+
json_fork: str, eels_fork: str
8585
) -> tuple[str, ...]:
8686
slow_tests = (
8787
"CALLBlake2f_MaxRounds",
@@ -92,13 +92,13 @@ def get_exceptional_state_test_patterns(
9292
"GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json::CALLBlake2f_MaxRounds-fork_[Cancun-Prague]-d0g0v0",
9393
"GeneralStateTests/VMTests/vmPerformance/loopExp.json::loopExp-fork_[Cancun-Prague]-d[0-14]g0v0",
9494
"GeneralStateTests/VMTests/vmPerformance/loopMul.json::loopMul-fork_[Cancun-Prague]-d[0-2]g0v0",
95-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{network}-state_test-bls_pairing_non-degeneracy-]",
96-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{network}-state_test-bls_pairing_bilinearity-]",
97-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{network}-state_test-bls_pairing_e(G1,-G2)=e(-G1,G2)-]",
98-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{network}-state_test-bls_pairing_e(aG1,bG2)=e(abG1,G2)-]",
99-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{network}-state_test-bls_pairing_e(aG1,bG2)=e(G1,abG2)-]",
100-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{network}-state_test-inf_pair-]",
101-
f"tests/{package}/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid[fork_{network}-state_test-multi_inf_pair-]",
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-]",
102102
)
103103

104104
return slow_tests

tests/json_infra/helpers/load_blockchain_tests.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def add_block_to_chain(
131131

132132

133133
# Functions that fetch individual test cases
134-
def load_json_fixture(test_file: str, network: str) -> Generator:
134+
def load_json_fixture(test_file: str, json_fork: str) -> Generator:
135135
# Extract the pure basename of the file without the path to the file.
136136
# Ex: Extract "world.json" from "path/to/file/world.json"
137137
# Extract the filename without the extension. Ex: Extract "world" from
@@ -145,7 +145,7 @@ def load_json_fixture(test_file: str, network: str) -> Generator:
145145
if "network" not in test:
146146
continue
147147

148-
if test["network"] == network:
148+
if test["network"] == json_fork:
149149
found_keys.append(key)
150150

151151
if not any(found_keys):
@@ -155,22 +155,22 @@ def load_json_fixture(test_file: str, network: str) -> Generator:
155155
yield {
156156
"test_file": test_file,
157157
"test_key": _key,
158-
"network": network,
158+
"json_fork": json_fork,
159159
}
160160

161161

162162
def fetch_blockchain_tests(
163-
network: str,
163+
json_fork: str,
164164
) -> Generator[Dict | ParameterSet, None, None]:
165165
# Filter FORKS based on fork_option parameter
166-
package = cast(str, FORKS[network]["package"])
167-
test_dirs = cast(list[str], FORKS[network]["blockchain_test_dirs"])
166+
eels_fork = cast(str, FORKS[json_fork]["eels_fork"])
167+
test_dirs = cast(list[str], FORKS[json_fork]["blockchain_test_dirs"])
168168

169169
(
170170
slow_list,
171171
ignore_list,
172172
big_memory_list,
173-
) = get_exceptional_blockchain_test_patterns(network, package)
173+
) = get_exceptional_blockchain_test_patterns(json_fork, eels_fork)
174174
all_slow = [re.compile(x) for x in slow_list]
175175
all_big_memory = [re.compile(x) for x in big_memory_list]
176176
all_ignore = [re.compile(x) for x in ignore_list]
@@ -192,7 +192,7 @@ def fetch_blockchain_tests(
192192
# Start yielding individual test cases from the file list
193193
for _test_file in files_to_iterate:
194194
try:
195-
for _test_case in load_json_fixture(_test_file, network):
195+
for _test_case in load_json_fixture(_test_file, json_fork):
196196
# _identifier could identify files, folders through test_file
197197
# individual cases through test_key
198198
_identifier = (
@@ -202,7 +202,7 @@ def fetch_blockchain_tests(
202202
+ _test_case["test_key"]
203203
+ ")"
204204
)
205-
_test_case["package"] = package
205+
_test_case["eels_fork"] = eels_fork
206206
if any(x.search(_identifier) for x in all_ignore):
207207
continue
208208
elif any(x.search(_identifier) for x in all_slow):

tests/json_infra/helpers/load_state_tests.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
parser = create_parser()
2020

2121

22-
def fetch_state_tests(network: str) -> Generator:
22+
def fetch_state_tests(json_fork: str) -> Generator:
2323
"""
2424
Fetches all the general state tests from the given directory
2525
"""
2626
# Filter FORKS based on fork_option parameter
27-
package = cast(str, FORKS[network]["package"])
28-
test_dirs = cast(list[str], FORKS[network]["state_test_dirs"])
27+
eels_fork = cast(str, FORKS[json_fork]["eels_fork"])
28+
test_dirs = cast(list[str], FORKS[json_fork]["state_test_dirs"])
2929

30-
slow_tests = get_exceptional_state_test_patterns(network, package)
30+
slow_tests = get_exceptional_state_test_patterns(json_fork, eels_fork)
3131

3232
# Get all the files to iterate over from both eest_tests_path and ethereum_tests_path
3333
all_jsons = []
@@ -40,14 +40,14 @@ def fetch_state_tests(network: str) -> Generator:
4040
test_cases = read_test_cases(test_file_path)
4141

4242
for test_case in test_cases:
43-
if test_case.fork_name != network:
43+
if test_case.fork_name != json_fork:
4444
continue
4545

4646
test_case_dict = {
4747
"test_file": test_case.path,
4848
"test_key": test_case.key,
4949
"index": test_case.index,
50-
"network": network,
50+
"json_fork": json_fork,
5151
}
5252

5353
if test_case.key in slow_tests:
@@ -75,7 +75,7 @@ def run_state_test(test_case: Dict[str, str]) -> None:
7575
test_file = test_case["test_file"]
7676
test_key = test_case["test_key"]
7777
index = test_case["index"]
78-
network = test_case["network"]
78+
json_fork = test_case["json_fork"]
7979
with open(test_file) as f:
8080
tests = json.load(f)
8181

@@ -88,7 +88,7 @@ def run_state_test(test_case: Dict[str, str]) -> None:
8888

8989
alloc = tests[test_key]["pre"]
9090

91-
post = tests[test_key]["post"][network][index]
91+
post = tests[test_key]["post"][json_fork][index]
9292
post_hash = post["hash"]
9393
d = post["indexes"]["data"]
9494
g = post["indexes"]["gas"]
@@ -130,7 +130,7 @@ def run_state_test(test_case: Dict[str, str]) -> None:
130130
"--input.txs",
131131
"stdin",
132132
"--state.fork",
133-
f"{network}",
133+
f"{json_fork}",
134134
"--state-test",
135135
]
136136
t8n_options = parser.parse_args(t8n_args)

tests/json_infra/test_blockchain_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def _generate_test_function(fork_name: str) -> Callable:
2121
)
2222
def test_func(blockchain_test_case: Dict) -> None:
2323
load = Load(
24-
blockchain_test_case["network"], blockchain_test_case["package"]
24+
blockchain_test_case["json_fork"],
25+
blockchain_test_case["eels_fork"],
2526
)
2627
run_blockchain_st_test(blockchain_test_case, load=load)
2728

0 commit comments

Comments
 (0)