Skip to content

test_migrated_valid_invalid()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_migrated_valid_invalid.py::test_migrated_valid_invalid@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_migrated_valid_invalid.py::test_migrated_valid_invalid --fork Osaka

Verify EOF container construction and exception.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_migrated_valid_invalid.py
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
@pytest.mark.parametrize(
    "eof_code,exception",
    [
        pytest.param(
            # Deployed code without data section
            Container(
                name="EOF1V3540_0001",
                sections=[
                    Section.Code(code=Op.PUSH1[0] + Op.POP + Op.STOP),
                ],
            ),
            None,
            id="EOF1V3540_0001_deployed_code_without_data_section",
        ),
        pytest.param(
            # Deployed code with data section
            Container(
                name="EOF1V3540_0002",
                sections=[
                    Section.Code(code=Op.PUSH1[0] + Op.POP + Op.STOP),
                    Section.Data("aabbccdd"),
                ],
            ),
            None,
            id="EOF1V3540_0002_deployed_code_with_data_section",
        ),
        pytest.param(
            # Empty code section with non-empty data section
            Container(
                sections=[Section.Code(code_outputs=0), Section.Data("aabb")],
                expected_bytecode="ef000101000402000100000400020000000000aabb",
            ),
            EOFException.ZERO_SECTION_SIZE,
            id="EOF1I3540_0012_empty_code_section_with_non_empty_data_section",
        ),
        pytest.param(
            # No section terminator after data section size
            bytes.fromhex("ef00010100040200010001040002"),
            EOFException.MISSING_HEADERS_TERMINATOR,
            id="EOF1I3540_0020_no_section_terminator_after_data_section_size",
        ),
        pytest.param(
            # No type section contents
            bytes.fromhex("ef0001010004020001000104000200"),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0021_no_type_section_contents",
        ),
        pytest.param(
            # Type section contents (no outputs and max stack)
            bytes.fromhex("ef000101000402000100010400020000"),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0022_invalid_type_section_no_outputs_and_max_stack",
        ),
        pytest.param(
            # Type section contents (no max stack)
            bytes.fromhex("ef00010100040200010001040002000000"),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0023_invalid_type_section_no_max_stack",
        ),
        pytest.param(
            # Type section contents (max stack incomplete)
            bytes.fromhex("ef0001010004020001000104000200000000"),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0024_invalid_type_section_max_stack_incomplete",
        ),
        pytest.param(
            # No code section contents
            bytes.fromhex("ef000101000402000100010400020000000000"),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0025_no_code_section_contents",
        ),
        pytest.param(
            # Code section contents incomplete
            bytes.fromhex("ef0001010004020001002904000000000000027f"),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0026_code_section_contents_incomplete",
        ),
        pytest.param(
            # Trailing bytes after code section
            bytes.fromhex("ef0001 010004 0200010001 040000 00 00800000 fe aabbcc"),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0027_trailing_bytes_after_code_section",
        ),
        pytest.param(
            # Trailing bytes after code section with wrong first section type
            bytes.fromhex("ef0001 010004 0200010001 040000 00 00000000 fe aabbcc"),
            [EOFException.INVALID_FIRST_SECTION_TYPE, EOFException.INVALID_SECTION_BODIES_SIZE],
            id="EOF1I3540_0027_trailing_bytes_after_code_section_with_wrong_first_section_type",
        ),
        pytest.param(
            # Empty code section
            bytes.fromhex("ef000101000402000100000400000000000000"),
            EOFException.ZERO_SECTION_SIZE,
            id="EOF1I3540_0028_empty_code_section",
        ),
        pytest.param(
            # Code section preceding type section
            bytes.fromhex("ef000102000100010100040400020000000000feaabb"),
            [EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0030_code_section_preceding_type_section",
        ),
        pytest.param(
            # Data section preceding type section
            bytes.fromhex("ef000104000201000402000100010000000000feaabb"),
            [EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0031_data_section_preceding_type_section",
        ),
        pytest.param(
            # Data section preceding code section
            bytes.fromhex("ef000101000404000202000100010000000000feaabb"),
            [EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0032_data_section_preceding_code_section",
        ),
        pytest.param(
            # Data section without code section
            bytes.fromhex("ef00010100040400020000000000aabb"),
            [EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0033_data_section_without_code_section",
        ),
        pytest.param(
            # No data section
            bytes.fromhex("ef000101000402000100010000000000fe"),
            [EOFException.MISSING_DATA_SECTION, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0034_no_data_section",
        ),
        pytest.param(
            # Trailing bytes after data section
            Container(
                sections=[
                    Section.Code(Op.INVALID),
                    Section.Data("aabb"),
                ],
                extra="ccdd",
                expected_bytecode="ef0001 010004 0200010001 040002 00 00800000 fe aabbccdd",
            ),
            EOFException.INVALID_SECTION_BODIES_SIZE,
            id="EOF1I3540_0035_trailing_bytes_after_data_section",
        ),
        pytest.param(
            # Trailing bytes after data section with wrong first section type
            bytes.fromhex("ef0001 010004 0200010001 040002 00 00000000 fe aabbccdd"),
            [EOFException.INVALID_FIRST_SECTION_TYPE, EOFException.INVALID_SECTION_BODIES_SIZE],
            id="EOF1I3540_0035_trailing_bytes_after_data_section_with_wrong_first_section_type",
        ),
        pytest.param(
            # Multiple data sections
            bytes.fromhex("ef000101000402000100010400020400020000000000feaabbaabb"),
            [EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0036_multiple_data_sections",
        ),
        pytest.param(
            # Multiple code and data sections
            bytes.fromhex("ef000101000802000200010001040002040002000000000000000000fefeaabbaabb"),
            [EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0037_multiple_code_and_data_sections",
        ),
        pytest.param(
            # Unknown section ID (at the beginning)
            bytes.fromhex("ef000105000101000402000100010400000000000000fe"),
            [EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0038_unknown_section_id_at_the_beginning_05",
        ),
        pytest.param(
            # Unknown section ID (at the beginning)
            bytes.fromhex("ef000106000101000402000100010400000000000000fe"),
            [EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0039_unknown_section_id_at_the_beginning_06",
        ),
        pytest.param(
            # Unknown section ID (at the beginning)
            bytes.fromhex("ef0001ff000101000402000100010400000000000000fe"),
            [EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0040_unknown_section_id_at_the_beginning_ff",
        ),
        pytest.param(
            # Unknown section ID (after types section)
            bytes.fromhex("ef000101000405000102000100010400000000000000fe"),
            [EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0041_unknown_section_id_after_types_section_05",
        ),
        pytest.param(
            # Unknown section ID (after types section)
            bytes.fromhex("ef000101000406000102000100010400000000000000fe"),
            [EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0042_unknown_section_id_after_types_section_06",
        ),
        pytest.param(
            # Unknown section ID (after types section)
            bytes.fromhex("ef0001010004ff000102000100010400000000000000fe"),
            [EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0043_unknown_section_id_after_types_section_ff",
        ),
        pytest.param(
            # Unknown section ID (after code section)
            bytes.fromhex("ef000101000402000100010500010400000000000000fe"),
            [EOFException.MISSING_DATA_SECTION, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0044_unknown_section_id_after_code_section_05",
        ),
        pytest.param(
            # Unknown section ID (after code section)
            bytes.fromhex("ef000101000402000100010600010400000000000000fe"),
            [EOFException.MISSING_DATA_SECTION, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0045_unknown_section_id_after_code_section_06",
        ),
        pytest.param(
            # Unknown section ID (after code section)
            bytes.fromhex("ef00010100040200010001ff00010400000000000000fe"),
            [EOFException.MISSING_DATA_SECTION, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0046_unknown_section_id_after_code_section_ff",
        ),
        pytest.param(
            # Unknown section ID (after data section)
            bytes.fromhex("ef000101000402000100010400000500010000000000fe"),
            [EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0047_unknown_section_id_after_data_section_05",
        ),
        pytest.param(
            # Unknown section ID (after data section)
            bytes.fromhex("ef000101000402000100010400000600010000000000fe"),
            [EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0048_unknown_section_id_after_data_section_06",
        ),
        pytest.param(
            # Unknown section ID (after data section)
            bytes.fromhex("ef00010100040200010001040000ff00010000000000fe"),
            [EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
            id="EOF1I3540_0049_unknown_section_id_after_data_section_ff",
        ),
        pytest.param(
            Container(
                name="EOF1I3540_0002 (Invalid) Invalid magic",
                raw_bytes="ef010101000402000100010400000000000000fe",
            ),
            EOFException.INVALID_MAGIC,
            id="EOF1I3540_0002_invalid_incorrect_magic_01",
        ),
        pytest.param(
            Container(
                name="EOF1I3540_0003",
                raw_bytes="ef020101000402000100010400000000000000fe",
            ),
            EOFException.INVALID_MAGIC,
            id="EOF1I3540_0003_invalid_incorrect_magic_02",
        ),
        pytest.param(
            Container(
                name="EOF1I3540_0004",
                raw_bytes="efff0101000402000100010400000000000000fe",
            ),
            EOFException.INVALID_MAGIC,
            id="EOF1I3540_0004_invalid_incorrect_magic_ff",
        ),
        pytest.param(
            Container(
                name="EOF1I3540_0006 (Invalid) Invalid version",
                raw_bytes="ef000001000402000100010400000000000000fe",
            ),
            EOFException.INVALID_VERSION,
            id="EOF1I3540_0006_invalid_incorrect_version_00",
        ),
        pytest.param(
            Container(
                name="EOF1I3540_0007",
                raw_bytes="ef000201000402000100010400000000000000fe",
            ),
            EOFException.INVALID_VERSION,
            id="EOF1I3540_0007_invalid_incorrect_version_02",
        ),
        pytest.param(
            Container(
                name="EOF1I3540_0008",
                raw_bytes="ef00ff01000402000100010400000000000000fe",
            ),
            EOFException.INVALID_VERSION,
            id="EOF1I3540_0008_invalid_incorrect_version_ff",
        ),
    ],
)
def test_migrated_valid_invalid(
    eof_test: EOFTestFiller,
    eof_code: Container | bytes,
    exception: EOFExceptionInstanceOrList | None,
):
    """Verify EOF container construction and exception."""
    eof_test(
        container=eof_code,
        expect_exception=exception,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) eof_code exception
...fork_Osaka-eof_test-EOF1V3540_0001_deployed_code_without_data_section EOF1V3540_0001 None
...fork_Osaka-eof_test-EOF1V3540_0002_deployed_code_with_data_section EOF1V3540_0002 None
...fork_Osaka-eof_test-EOF1I3540_0012_empty_code_section_with_non_empty_data_section b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x00\x04\x00\x02\x00\x00\x00\x00\x00\xaa\xbb' EOFException.ZERO_SECTION_SIZE
...fork_Osaka-eof_test-EOF1I3540_0020_no_section_terminator_after_data_section_size ef00010100040200010001040002 EOFException.MISSING_HEADERS_TERMINATOR
...fork_Osaka-eof_test-EOF1I3540_0021_no_type_section_contents ef0001010004020001000104000200 EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0022_invalid_type_section_no_outputs_and_max_stack ef000101000402000100010400020000 EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0023_invalid_type_section_no_max_stack ef000101000402000100010400020000 00 EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0024_invalid_type_section_max_stack_incomplete ef000101000402000100010400020000 0000 EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0025_no_code_section_contents ef000101000402000100010400020000 000000 EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0026_code_section_contents_incomplete ef000101000402000100290400000000 0000027f EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0027_trailing_bytes_after_code_section ef000101000402000100010400000000 800000feaabbcc EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0027_trailing_bytes_after_code_section_with_wrong_first_section_type ef000101000402000100010400000000 000000feaabbcc [, ]
...fork_Osaka-eof_test-EOF1I3540_0028_empty_code_section ef000101000402000100000400000000 000000 EOFException.ZERO_SECTION_SIZE
...fork_Osaka-eof_test-EOF1I3540_0030_code_section_preceding_type_section ef000102000100010100040400020000 000000feaabb [, ]
...fork_Osaka-eof_test-EOF1I3540_0031_data_section_preceding_type_section ef000104000201000402000100010000 000000feaabb [, ]
...fork_Osaka-eof_test-EOF1I3540_0032_data_section_preceding_code_section ef000101000404000202000100010000 000000feaabb [, ]
...fork_Osaka-eof_test-EOF1I3540_0033_data_section_without_code_section ef00010100040400020000000000aabb [, ]
...fork_Osaka-eof_test-EOF1I3540_0034_no_data_section ef000101000402000100010000000000 fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0035_trailing_bytes_after_data_section b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\x04\x00\x02\x00\x00\x80\x00\x00\xfe\xaa\xbb\xcc\xdd' EOFException.INVALID_SECTION_BODIES_SIZE
...fork_Osaka-eof_test-EOF1I3540_0035_trailing_bytes_after_data_section_with_wrong_first_section_type ef000101000402000100010400020000 000000feaabbccdd [, ]
...fork_Osaka-eof_test-EOF1I3540_0036_multiple_data_sections ef000101000402000100010400020400 020000000000feaabbaabb [, ]
...fork_Osaka-eof_test-EOF1I3540_0037_multiple_code_and_data_sections ef000101000802000200010001040002 040002000000000000000000fefeaabb aabb [, ]
...fork_Osaka-eof_test-EOF1I3540_0038_unknown_section_id_at_the_beginning_05 ef000105000101000402000100010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0039_unknown_section_id_at_the_beginning_06 ef000106000101000402000100010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0040_unknown_section_id_at_the_beginning_ff ef0001ff000101000402000100010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0041_unknown_section_id_after_types_section_05 ef000101000405000102000100010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0042_unknown_section_id_after_types_section_06 ef000101000406000102000100010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0043_unknown_section_id_after_types_section_ff ef0001010004ff000102000100010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0044_unknown_section_id_after_code_section_05 ef000101000402000100010500010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0045_unknown_section_id_after_code_section_06 ef000101000402000100010600010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0046_unknown_section_id_after_code_section_ff ef00010100040200010001ff00010400 000000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0047_unknown_section_id_after_data_section_05 ef000101000402000100010400000500 010000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0048_unknown_section_id_after_data_section_06 ef000101000402000100010400000600 010000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0049_unknown_section_id_after_data_section_ff ef00010100040200010001040000ff00 010000000000fe [, ]
...fork_Osaka-eof_test-EOF1I3540_0002_invalid_incorrect_magic_01 EOF1I3540_0002 (Invalid) Invalid magic EOFException.INVALID_MAGIC
...fork_Osaka-eof_test-EOF1I3540_0003_invalid_incorrect_magic_02 EOF1I3540_0003 EOFException.INVALID_MAGIC
...fork_Osaka-eof_test-EOF1I3540_0004_invalid_incorrect_magic_ff EOF1I3540_0004 EOFException.INVALID_MAGIC
...fork_Osaka-eof_test-EOF1I3540_0006_invalid_incorrect_version_00 EOF1I3540_0006 (Invalid) Invalid version EOFException.INVALID_VERSION
...fork_Osaka-eof_test-EOF1I3540_0007_invalid_incorrect_version_02 EOF1I3540_0007 EOFException.INVALID_VERSION
...fork_Osaka-eof_test-EOF1I3540_0008_invalid_incorrect_version_ff EOF1I3540_0008 EOFException.INVALID_VERSION