99import pytest
1010from semver import Version
1111
12- from ethereum_test_forks import Berlin , Fork , Istanbul , London
12+ from ethereum_test_forks import Berlin , Fork , Istanbul , London , Merge , Shanghai
1313from evm_transition_tool import GethTransitionTool
1414
1515from ..code import Yul
1616from ..common import Account , Block , Environment , TestAddress , Transaction , to_json
1717from ..filling import fill_test
18- from ..spec import BlockchainTest , StateTest
18+ from ..spec import BaseTestConfig , BlockchainTest , StateTest
1919from .conftest import SOLC_PADDING_VERSION
2020
2121
22- def remove_info (fixture_json : Dict [str , Any ]):
22+ def remove_info (fixture_json : Dict [str , Any ]): # noqa: D103
2323 for t in fixture_json :
2424 if "_info" in fixture_json [t ]:
2525 del fixture_json [t ]["_info" ]
@@ -50,7 +50,7 @@ def hash(request: pytest.FixtureRequest, solc_version: Version):
5050 ],
5151 indirect = ["hash" ],
5252)
53- def test_make_genesis (fork : Fork , hash : bytes ):
53+ def test_make_genesis (fork : Fork , hash : bytes ): # noqa: D103
5454 env = Environment ()
5555
5656 pre = {
@@ -86,13 +86,15 @@ def test_make_genesis(fork: Fork, hash: bytes):
8686
8787
8888@pytest .mark .parametrize (
89- "fork,expected_json_file" ,
89+ "fork,enable_hive, expected_json_file" ,
9090 [
91- (Istanbul , "chainid_istanbul_filled.json" ),
92- (London , "chainid_london_filled.json" ),
91+ (Istanbul , False , "chainid_istanbul_filled.json" ),
92+ (London , False , "chainid_london_filled.json" ),
93+ (Merge , True , "chainid_merge_filled_hive.json" ),
94+ (Shanghai , True , "chainid_shanghai_filled_hive.json" ),
9395 ],
9496)
95- def test_fill_state_test (fork : Fork , expected_json_file : str ):
97+ def test_fill_state_test (fork : Fork , expected_json_file : str , enable_hive : bool ):
9698 """
9799 Test `ethereum_test.filler.fill_fixtures` with `StateTest`.
98100 """
@@ -125,7 +127,14 @@ def test_fill_state_test(fork: Fork, expected_json_file: str):
125127 ),
126128 }
127129
128- state_test = StateTest (env = env , pre = pre , post = post , txs = [tx ], tag = "my_chain_id_test" )
130+ state_test = StateTest (
131+ env = env ,
132+ pre = pre ,
133+ post = post ,
134+ txs = [tx ],
135+ tag = "my_chain_id_test" ,
136+ base_test_config = BaseTestConfig (enable_hive = enable_hive ),
137+ )
129138
130139 t8n = GethTransitionTool ()
131140
@@ -138,6 +147,7 @@ def test_fill_state_test(fork: Fork, expected_json_file: str):
138147 spec = None ,
139148 ),
140149 }
150+
141151 with open (
142152 os .path .join (
143153 "src" ,
@@ -148,13 +158,24 @@ def test_fill_state_test(fork: Fork, expected_json_file: str):
148158 )
149159 ) as f :
150160 expected = json .load (f )
161+
151162 fixture_json = to_json (fixture )
152163 remove_info (fixture_json )
164+ with open ("gen.json" , "w" ) as fr :
165+ json .dump (fixture_json , fr , indent = 4 )
153166 assert fixture_json == expected
154167
155168
156- @pytest .mark .parametrize ("fork" , [London ])
157- def test_fill_london_blockchain_test_valid_txs (fork : Fork , solc_version : str ):
169+ @pytest .mark .parametrize (
170+ "fork,enable_hive,expected_json_file" ,
171+ [
172+ (London , False , "blockchain_london_valid_filled.json" ),
173+ (Shanghai , True , "blockchain_shanghai_valid_filled_hive.json" ),
174+ ],
175+ )
176+ def test_fill_blockchain_valid_txs (
177+ fork : Fork , solc_version : str , enable_hive : bool , expected_json_file : str
178+ ):
158179 """
159180 Test `ethereum_test.filler.fill_fixtures` with `BlockchainTest`.
160181 """
@@ -411,7 +432,8 @@ def test_fill_london_blockchain_test_valid_txs(fork: Fork, solc_version: str):
411432 post = post ,
412433 blocks = blocks ,
413434 genesis_environment = genesis_environment ,
414- tag = "fill_london_blockchain_test_valid_txs" ,
435+ tag = "my_blockchain_test_valid_txs" ,
436+ base_test_config = BaseTestConfig (enable_hive = enable_hive ),
415437 )
416438
417439 t8n = GethTransitionTool ()
@@ -432,7 +454,7 @@ def test_fill_london_blockchain_test_valid_txs(fork: Fork, solc_version: str):
432454 "ethereum_test_tools" ,
433455 "tests" ,
434456 "test_fixtures" ,
435- "blockchain_london_valid_filled.json" ,
457+ expected_json_file ,
436458 )
437459 ) as f :
438460 expected = json .load (f )
@@ -448,8 +470,16 @@ def test_fill_london_blockchain_test_valid_txs(fork: Fork, solc_version: str):
448470 assert fixture_json == expected
449471
450472
451- @pytest .mark .parametrize ("fork" , [London ])
452- def test_fill_london_blockchain_test_invalid_txs (fork : Fork , solc_version : str ):
473+ @pytest .mark .parametrize (
474+ "fork,enable_hive,expected_json_file" ,
475+ [
476+ (London , False , "blockchain_london_invalid_filled.json" ),
477+ (Shanghai , True , "blockchain_shanghai_invalid_filled_hive.json" ),
478+ ],
479+ )
480+ def test_fill_blockchain_invalid_txs (
481+ fork : Fork , solc_version : str , enable_hive : bool , expected_json_file : str
482+ ):
453483 """
454484 Test `ethereum_test.filler.fill_fixtures` with `BlockchainTest`.
455485 """
@@ -752,7 +782,7 @@ def test_fill_london_blockchain_test_invalid_txs(fork: Fork, solc_version: str):
752782 post = post ,
753783 blocks = blocks ,
754784 genesis_environment = genesis_environment ,
755- tag = "fill_london_blockchain_test_invalid_txs" ,
785+ base_test_config = BaseTestConfig ( enable_hive = enable_hive ) ,
756786 )
757787
758788 t8n = GethTransitionTool ()
@@ -773,7 +803,7 @@ def test_fill_london_blockchain_test_invalid_txs(fork: Fork, solc_version: str):
773803 "ethereum_test_tools" ,
774804 "tests" ,
775805 "test_fixtures" ,
776- "blockchain_london_invalid_filled.json" ,
806+ expected_json_file ,
777807 )
778808 ) as f :
779809 expected = json .load (f )
0 commit comments