Skip to content

Commit cb053e2

Browse files
committed
expand embedded container invalid tests
1 parent 54146ee commit cb053e2

File tree

1 file changed

+132
-10
lines changed

1 file changed

+132
-10
lines changed

tests/osaka/eip7692_eof_v1/converted/efValidation_EOF1_embedded_container_invalid_.py

+132-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import pytest
22

33
from ethereum_test_exceptions import EOFException
4-
from ethereum_test_types.eof.v1 import Container
4+
from ethereum_test_types.eof.v1 import Container, Section
5+
from ethereum_test_tools.vm.opcode import Opcodes as Op
56

67
REFERENCE_SPEC_GIT_PATH = "EIPS/eip-663.md"
78
REFERENCE_SPEC_VERSION = "b658bb87fe039d29e9475d5cfaebca9b92e0fca2"
@@ -12,47 +13,168 @@
1213
[
1314
Container(
1415
name="EOF1_embedded_container_invalid_0",
15-
raw_bytes="ef0001010004020001000603",
16+
raw_bytes=(
17+
[
18+
0xEF, 0x00, 0x01, # Version: 1
19+
0x01, 0x00, 0x04, # Types Length: 4
20+
0x02, 0x00, 0x01, # Code Sections (Length: 1)
21+
0x00, 0x06, # Code Section 0 (Length: 6)
22+
# --- Error: Invalid Container Header ---#
23+
0x03,
24+
]
25+
),
1626
validity_error=EOFException.INCOMPLETE_SECTION_NUMBER,
1727
),
1828
Container(
1929
name="EOF1_embedded_container_invalid_1",
20-
raw_bytes="ef000101000402000100060300",
30+
raw_bytes=(
31+
[
32+
0xEF, 0x00, 0x01, # Version: 1
33+
0x01, 0x00, 0x04, # Types Length: 4
34+
0x02, 0x00, 0x01, # Code Sections (Length: 1)
35+
0x00, 0x06, # Code Section 0 (Length: 6)
36+
# --- Error: Invalid Container Header ---#
37+
0x03,
38+
0x00,
39+
]
40+
),
2141
validity_error=EOFException.INCOMPLETE_SECTION_NUMBER,
2242
),
2343
Container(
2444
name="EOF1_embedded_container_invalid_2",
25-
raw_bytes="ef00010100040200010006030001",
45+
raw_bytes=(
46+
[
47+
0xEF, 0x00, 0x01, # Version: 1
48+
0x01, 0x00, 0x04, # Types Length: 4
49+
0x02, 0x00, 0x01, # Code Sections (Length: 1)
50+
0x00, 0x06, # Code Section 0 (Length: 6)
51+
# --- Error: Invalid Container Header ---#
52+
0x03,
53+
0x00,
54+
0x01,
55+
]
56+
),
2657
validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
2758
),
2859
Container(
2960
name="EOF1_embedded_container_invalid_3",
30-
raw_bytes="ef0001010004020001000603000100",
61+
raw_bytes=(
62+
[
63+
0xEF, 0x00, 0x01, # Version: 1
64+
0x01, 0x00, 0x04, # Types Length: 4
65+
0x02, 0x00, 0x01, # Code Sections (Length: 1)
66+
0x00, 0x06, # Code Section 0 (Length: 6)
67+
# --- Error: Invalid Container Header ---#
68+
0x03,
69+
0x00,
70+
0x01,
71+
0x00,
72+
]
73+
),
3174
validity_error=EOFException.INCOMPLETE_SECTION_SIZE,
3275
),
3376
Container(
3477
name="EOF1_embedded_container_invalid_4",
35-
raw_bytes="ef000101000402000100060300010014",
78+
raw_bytes=(
79+
[
80+
0xEF, 0x00, 0x01, # Version: 1
81+
0x01, 0x00, 0x04, # Types Length: 4
82+
0x02, 0x00, 0x01, # Code Sections (Length: 1)
83+
0x00, 0x06, # Code Section 0 (Length: 6)
84+
0x03, 0x00, 0x01, # Container Sections (Length: 1)
85+
0x00, 0x00,
86+
0x00, 0x14, # Container Section 0 (Length: 20)
87+
# --- Error: Invalid Data Header ---#
88+
]
89+
),
3690
validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
3791
),
3892
Container(
3993
name="EOF1_embedded_container_invalid_5",
40-
raw_bytes="ef00010100040200010006030000040000000080000160005d000000",
94+
raw_bytes=(
95+
[
96+
0xEF, 0x00, 0x01, # Version: 1
97+
0x01, 0x00, 0x04, # Types Length: 4
98+
0x02, 0x00, 0x01, # Code Sections (Length: 1)
99+
0x00, 0x06, # Code Section 0 (Length: 6)
100+
# --- Error: Invalid Container Header ---#
101+
0x03,
102+
0x00,
103+
0x00,
104+
0xFF,
105+
0x00,
106+
0x00,
107+
0x00,
108+
0x00,
109+
0x80,
110+
0x00,
111+
0x01,
112+
0x60,
113+
0x00,
114+
0xE1,
115+
0x00,
116+
0x00,
117+
0x00,
118+
]
119+
),
41120
validity_error=EOFException.ZERO_SECTION_SIZE,
42121
),
43122
Container(
44123
name="EOF1_embedded_container_invalid_6",
45-
raw_bytes="ef000101000402000100060300010000040000000080000160005d000000",
124+
sections=[
125+
Section.Code(
126+
code=Op.PUSH1[0] + Op.RJUMPI[0] + Op.STOP,
127+
max_stack_height=1,
128+
),
129+
Section.Container(
130+
container=Container(
131+
name="EOFV1_0001",
132+
raw_bytes=([]), # Empty subcontainer
133+
)
134+
),
135+
],
46136
validity_error=EOFException.ZERO_SECTION_SIZE,
47137
),
48138
Container(
49139
name="EOF1_embedded_container_invalid_7",
50-
raw_bytes="ef000101000402000100060300010014040000000080000160005d000000",
140+
raw_bytes=(
141+
[
142+
0xEF, 0x00, 0x01, # Version: 1
143+
0x01, 0x00, 0x04, # Types Length: 4
144+
0x02, 0x00, 0x01, # Code Sections (Length: 1)
145+
0x00, 0x06, # Code Section 0 (Length: 6)
146+
0x03, 0x00, 0x01, # Container Sections (Length: 1)
147+
0x00, 0x00,
148+
0x00, 0x14, # Container Section 0 (Length: 20)
149+
0xFF, 0x00, 0x00, # Data Length: 0
150+
0x00, # Terminator
151+
# Code Section 0 types
152+
0x00, # Inputs: 0
153+
0x80, # Outputs: 0 (Non-returning function)
154+
0x00, 0x01, # Max Stack Height: 1
155+
# Code Section 0
156+
0x60,0x00, # [0] PUSH1(0)
157+
0xE1,0x00,0x00, # [2] RJUMPI(0)
158+
0x00, # [5] STOP
159+
# --- Error: Invalid Container Content ---#
160+
]
161+
),
51162
validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
52163
),
53164
Container(
54165
name="EOF1_embedded_container_invalid_8",
55-
raw_bytes="ef0001010004020001000603010100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001040000000080000160005d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
166+
sections=[
167+
Section.Code(
168+
code=Op.PUSH1[0] + Op.RJUMPI[0] + Op.STOP,
169+
max_stack_height=1,
170+
),
171+
] + [
172+
Section.Container(
173+
container=Container(
174+
raw_bytes=([0x00]),
175+
)
176+
),
177+
] * 257,
56178
validity_error=EOFException.TOO_MANY_CONTAINERS,
57179
),
58180
],

0 commit comments

Comments
 (0)