1
1
"""Test suite for `ethereum_test.code` module."""
2
2
3
3
from string import Template
4
- from typing import Mapping , SupportsBytes
4
+ from typing import Mapping
5
5
6
6
import pytest
7
7
from semver import Version
8
8
9
9
from 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
11
11
from ethereum_test_fixtures import BlockchainFixture
12
12
from ethereum_test_forks import (
13
13
Cancun ,
14
14
Fork ,
15
15
Homestead ,
16
16
Shanghai ,
17
- get_closest_fork_with_solc_support ,
18
17
get_deployed_forks ,
19
18
)
20
19
from ethereum_test_specs import StateTest
21
20
from ethereum_test_types import Alloc , Environment , Transaction
22
21
from ethereum_test_vm import Opcodes as Op
23
22
from ethereum_test_vm import UndefinedOpcodes
24
23
25
- from ..code import CalldataCase , Case , Conditional , Initcode , Solc , Switch , Yul
24
+ from ..code import CalldataCase , Case , Conditional , Initcode , Switch
26
25
from .conftest import SOLC_PADDING_VERSION
27
26
28
27
@@ -32,27 +31,6 @@ def fork(request: pytest.FixtureRequest):
32
31
return request .param
33
32
34
33
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
-
56
34
@pytest .fixture ()
57
35
def expected_bytes (request : pytest .FixtureRequest , solc_version : Version , fork : Fork ):
58
36
"""Return the expected bytes for the test."""
@@ -74,83 +52,6 @@ def expected_bytes(request: pytest.FixtureRequest, solc_version: Version, fork:
74
52
raise Exception ("Unsupported expected_bytes type: {}" .format (type (expected_bytes )))
75
53
76
54
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
-
154
55
@pytest .mark .parametrize (
155
56
"initcode,bytecode" ,
156
57
[
0 commit comments