11"""Test suite for `ethereum_test.code` module.""" 
22
33from  string  import  Template 
4- from  typing  import  Mapping ,  SupportsBytes 
4+ from  typing  import  Mapping 
55
66import  pytest 
77from  semver  import  Version 
88
99from  ethereum_clis  import  TransitionTool 
10- from  ethereum_test_base_types  import  Account , Address , Bytes ,  Hash , TestAddress , TestPrivateKey 
10+ from  ethereum_test_base_types  import  Account , Address , Hash , TestAddress , TestPrivateKey 
1111from  ethereum_test_fixtures  import  BlockchainFixture 
1212from  ethereum_test_forks  import  (
1313    Cancun ,
1414    Fork ,
1515    Homestead ,
1616    Shanghai ,
17-     get_closest_fork_with_solc_support ,
1817    get_deployed_forks ,
1918)
2019from  ethereum_test_specs  import  StateTest 
2120from  ethereum_test_types  import  Alloc , Environment , Transaction 
2221from  ethereum_test_vm  import  Opcodes  as  Op 
2322from  ethereum_test_vm  import  UndefinedOpcodes 
2423
25- from  ..code  import  CalldataCase , Case , Conditional , Initcode , Solc ,  Switch ,  Yul 
24+ from  ..code  import  CalldataCase , Case , Conditional , Initcode , Switch 
2625from  .conftest  import  SOLC_PADDING_VERSION 
2726
2827
@@ -32,27 +31,6 @@ def fork(request: pytest.FixtureRequest):
3231    return  request .param 
3332
3433
35- @pytest .fixture () 
36- def  yul_code (
37-     request : pytest .FixtureRequest ,
38-     fork : Fork ,
39-     padding_before : str  |  None ,
40-     padding_after : str  |  None ,
41- ) ->  bytes :
42-     """Return the Yul code for the test.""" 
43-     yul_code_snippets  =  request .param 
44-     compiled_yul_code  =  b"" 
45-     if  padding_before  is  not None :
46-         compiled_yul_code  +=  Bytes (padding_before )
47-     for  yul_code  in  yul_code_snippets :
48-         compiled_yul_code  +=  bytes (
49-             Yul (yul_code , fork = get_closest_fork_with_solc_support (fork , Solc ().version ))
50-         )
51-     if  padding_after  is  not None :
52-         compiled_yul_code  +=  Bytes (padding_after )
53-     return  compiled_yul_code 
54- 
55- 
5634@pytest .fixture () 
5735def  expected_bytes (request : pytest .FixtureRequest , solc_version : Version , fork : Fork ):
5836    """Return the expected bytes for the test.""" 
@@ -74,83 +52,6 @@ def expected_bytes(request: pytest.FixtureRequest, solc_version: Version, fork:
7452    raise  Exception ("Unsupported expected_bytes type: {}" .format (type (expected_bytes )))
7553
7654
77- @pytest .mark .parametrize ( 
78-     ["yul_code" , "padding_before" , "padding_after" , "expected_bytes" ], 
79-     [ 
80-         pytest .param ( 
81-             ( 
82-                 """  
83-                 { 
84-                     sstore(1, 2) 
85-                 } 
86-                 """ ,
87-             ), 
88-             None , 
89-             None , 
90-             Template ("6002600155${solc_padding}" ), 
91-             id = "simple" , 
92-         ), 
93-         pytest .param ( 
94-             ( 
95-                 """  
96-                 { 
97-                     sstore(1, 2) 
98-                 } 
99-                 """ ,
100-             ), 
101-             None , 
102-             "0x00" , 
103-             Template ("6002600155${solc_padding}00" ), 
104-             id = "simple-with-padding" , 
105-         ), 
106-         pytest .param ( 
107-             ( 
108-                 """  
109-                 { 
110-                     sstore(1, 2) 
111-                 } 
112-                 """ ,
113-             ), 
114-             "0x00" , 
115-             None , 
116-             Template ("006002600155${solc_padding}" ), 
117-             id = "simple-with-padding-2" , 
118-         ), 
119-         pytest .param ( 
120-             ( 
121-                 """  
122-                 { 
123-                     sstore(1, 2) 
124-                 } 
125-                 """ ,
126-                 """  
127-                 { 
128-                     sstore(3, 4) 
129-                 } 
130-                 """ ,
131-             ), 
132-             None , 
133-             None , 
134-             Template ("6002600155${solc_padding}6004600355${solc_padding}" ), 
135-             id = "multiple" , 
136-         ), 
137-         pytest .param ( 
138-             ("{\n "  +  "\n " .join (["sstore({0}, {0})" .format (i ) for  i  in  range (5000 )]) +  "\n }" ,), 
139-             None , 
140-             None , 
141-             b"" .join ([b"\x60 "  +  i .to_bytes (1 , "big" ) +  b"\x80 \x55 "  for  i  in  range (256 )]) 
142-             +  b"" .join ([b"\x61 "  +  i .to_bytes (2 , "big" ) +  b"\x80 \x55 "  for  i  in  range (256 , 5000 )]), 
143-             id = "large" , 
144-         ), 
145-     ], 
146-     indirect = ["yul_code" , "expected_bytes" ], 
147- ) 
148- def  test_yul (  # noqa: D103 
149-     yul_code : SupportsBytes , expected_bytes : bytes , padding_before : str , padding_after : str 
150- ):
151-     assert  bytes (yul_code ) ==  expected_bytes 
152- 
153- 
15455@pytest .mark .parametrize ( 
15556    "initcode,bytecode" , 
15657    [ 
0 commit comments