Skip to content

test_invalid_containers()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_invalid_containers@008e492e.

Generate fixtures for these test cases for Osaka with:

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

Test invalid containers.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py
 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
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
@pytest.mark.parametrize(
    "container",
    [
        Container(
            name="empty_container",
            raw_bytes=b"",
            validity_error=[
                EOFException.INVALID_MAGIC,
            ],
        ),
        Container(
            name="single_code_section_no_data_section",
            sections=[
                Section.Code(Op.STOP),
            ],
            auto_data_section=False,
            validity_error=[
                EOFException.MISSING_DATA_SECTION,
                EOFException.UNEXPECTED_HEADER_KIND,
            ],
        ),
        Container(
            name="incomplete_magic",
            raw_bytes="ef",
            validity_error=EOFException.INVALID_MAGIC,
        ),
        Container(
            name="no_version",
            raw_bytes="ef00",
            validity_error=[EOFException.INVALID_VERSION, EOFException.INVALID_MAGIC],
        ),
        Container(
            name="no_type_header",
            raw_bytes="ef00 01",
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="no_type_section_size",
            raw_bytes="ef00 01 01",
            validity_error=[
                EOFException.MISSING_HEADERS_TERMINATOR,
                EOFException.INVALID_TYPE_SECTION_SIZE,
            ],
        ),
        Container(
            name="incomplete_type_section_size",
            raw_bytes="ef00010100",
            validity_error=[
                EOFException.INCOMPLETE_SECTION_SIZE,
                EOFException.INVALID_TYPE_SECTION_SIZE,
            ],
        ),
        Container(
            name="no_code_header",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04]),
            validity_error=[
                EOFException.MISSING_CODE_HEADER,
                EOFException.MISSING_HEADERS_TERMINATOR,
            ],
        ),
        Container(
            name="no_code_header_2",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0xFE]),
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_code_header_3",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x00]),
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_code_header_4",
            sections=[
                Section(kind=SectionKind.TYPE, data="00800000"),
                Section.Data("da"),
            ],
            expected_bytecode="ef0001 010004 040001 00 00800000 da",
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="code_section_count_missing",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02]),
            validity_error=EOFException.INCOMPLETE_SECTION_NUMBER,
        ),
        Container(
            name="code_section_count_incomplete",
            raw_bytes="ef00 01 01 0004 02 00",
            validity_error=EOFException.INCOMPLETE_SECTION_NUMBER,
        ),
        Container(
            name="code_section_size_missing",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02, 0x00, 0x01]),
            validity_error=[
                EOFException.MISSING_HEADERS_TERMINATOR,
                EOFException.ZERO_SECTION_SIZE,
            ],
        ),
        Container(
            name="code_section_size_incomplete",
            raw_bytes="ef00 01 01 0004 02 0001 00",
            validity_error=[EOFException.INCOMPLETE_SECTION_SIZE, EOFException.ZERO_SECTION_SIZE],
        ),
        Container(
            name="code_section_count_0x8000_truncated",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02, 0x80, 0x00]),
            validity_error=EOFException.TOO_MANY_CODE_SECTIONS,
        ),
        Container(
            name="code_section_count_0xFFFF_truncated",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02, 0xFF, 0xFF]),
            validity_error=EOFException.TOO_MANY_CODE_SECTIONS,
        ),
        Container(
            name="code_section_count_0x8000",
            raw_bytes=bytes(
                [0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02, 0x80, 0x00] + [0x00, 0x01] * 0x8000
            ),
            validity_error=EOFException.CONTAINER_SIZE_ABOVE_LIMIT,
        ),
        Container(
            name="code_section_count_0xFFFF",
            raw_bytes=bytes(
                [0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02, 0xFF, 0xFF] + [0x00, 0x01] * 0xFFFF
            ),
            validity_error=EOFException.CONTAINER_SIZE_ABOVE_LIMIT,
        ),
        Container(
            name="code_section_size_0x8000_truncated",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02, 0x00, 0x01, 0x80, 0x00]),
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="code_section_size_0xFFFF_truncated",
            raw_bytes=bytes([0xEF, 0x00, 0x01, 0x01, 0x00, 0x04, 0x02, 0x00, 0x01, 0xFF, 0xFF]),
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="terminator_incomplete",
            header_terminator=b"",
            sections=[
                Section(kind=SectionKind.TYPE, data=b"", custom_size=4),
                Section.Code(code=b"", custom_size=0x01),
            ],
            expected_bytecode="ef00 01 01 0004 02 0001 0001 04 0000",
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="truncated_header_data_section",
            raw_bytes="ef00 01 01 0004 02 0001 0001",
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="no_data_section_size",
            raw_bytes="ef00 01 01 0004 02 0001 0001 04",
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="data_section_size_incomplete",
            raw_bytes="ef00 01 01 0004 02 0001 0001 04 00",
            validity_error=EOFException.INCOMPLETE_SECTION_SIZE,
        ),
        Container(
            name="no_container_section_count",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03",
            validity_error=EOFException.INCOMPLETE_SECTION_NUMBER,
        ),
        Container(
            name="incomplete_container_section_count",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 00",
            validity_error=EOFException.INCOMPLETE_SECTION_NUMBER,
        ),
        Container(
            name="zero_container_section_count",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0000 04 0000 00 00800000 00",
            validity_error=EOFException.ZERO_SECTION_SIZE,
        ),
        Container(
            name="no_container_section_size",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0001",
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="incomplete_container_section_size",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0001 00",
            validity_error=EOFException.INCOMPLETE_SECTION_SIZE,
        ),
        Container(
            name="incomplete_container_section_size_2",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0002 0001",
            validity_error=EOFException.INCOMPLETE_SECTION_SIZE,
        ),
        Container(
            name="incomplete_container_section_size_3",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0002 0001 00",
            validity_error=EOFException.INCOMPLETE_SECTION_SIZE,
        ),
        Container(
            name="zero_size_container_section",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0001 0000 04 0000 00 00800000 00",
            validity_error=EOFException.ZERO_SECTION_SIZE,
        ),
        Container(
            name="truncated_header_data_section_with_container_section",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0001 0001",
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="no_data_section_size_with_container_section",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0001 0001 04",
            validity_error=EOFException.MISSING_HEADERS_TERMINATOR,
        ),
        Container(
            name="data_section_size_incomplete_with_container_section",
            raw_bytes="ef00 01 01 0004 02 0001 0001 03 0001 0001 04 00",
            validity_error=EOFException.INCOMPLETE_SECTION_SIZE,
        ),
        Container(
            # EOF code missing mandatory type section
            name="EOF1I4750_0001",
            raw_bytes="ef000102000100010400000000800000fe",
            validity_error=EOFException.MISSING_TYPE_HEADER,
        ),
        Container(
            # EOF code containing multiple type headers
            name="multiple_type_headers_1",  # EOF1I4750_0002
            raw_bytes="ef00010100040100040400000000800000fe",
            validity_error=EOFException.MISSING_CODE_HEADER,
        ),
        Container(
            # EOF code containing multiple type headers, second one matches code length
            name="multiple_type_headers_2",
            raw_bytes="ef00010100040100010400000000800000fe",
            validity_error=EOFException.MISSING_CODE_HEADER,
        ),
        Container(
            # EOF code containing multiple type headers followed by 2 code sections
            name="multiple_type_headers_3",
            sections=[
                Section(kind=SectionKind.TYPE, data="00800000"),
                Section(kind=SectionKind.TYPE, data="00800000"),
                Section.Code(Op.JUMPF[1]),
                Section.Code(Op.INVALID),
            ],
            validity_error=EOFException.MISSING_CODE_HEADER,
        ),
        Container(
            # EOF code containing type section size (Size 1)
            name="EOF1I4750_0003",
            raw_bytes="ef000101000102000100010400000000800000fe",
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            # EOF code containing type section size (Size 8 - 1 Code section)
            name="EOF1I4750_0004",
            raw_bytes="ef000101000802000100010400000000800000fe",
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            # EOF code containing type section size (Size 8 - 3 Code sections)
            name="EOF1I4750_0005",
            raw_bytes="ef0001010008020003000100010001040000000080000000800000fefefe",
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            # EOF code containing invalid first section type (1,0)
            name="EOF1I4750_0006",
            raw_bytes="ef000101000402000100010400000001000000fe",
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            # EOF code containing invalid first section type (0,1)
            name="EOF1I4750_0007",
            raw_bytes="ef000101000402000100010400000000010000fe",
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            # EOF code containing invalid first section type (2,3)
            name="EOF1I4750_0008",
            raw_bytes="ef000101000402000100010400000002030000fe",
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="no_sections",
            sections=[],
            auto_data_section=False,
            auto_type_section=AutoSection.NONE,
            expected_bytecode="ef0001 00",
            validity_error=[EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_code_section_header",
            sections=[
                Section(kind=SectionKind.TYPE, data=b"\0\x80\0\0"),
                Section.Data("0x00"),
            ],
            expected_bytecode="ef00 01 01 0004 04 0001 00 00800000 00",
            auto_type_section=AutoSection.NONE,
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="too_many_code_sections",
            sections=[
                Section.Code(Op.JUMPF[i + 1] if i < MAX_CODE_SECTIONS else Op.STOP)
                for i in range(MAX_CODE_SECTIONS + 1)
            ],
            validity_error=EOFException.TOO_MANY_CODE_SECTIONS,
        ),
        Container(
            name="zero_code_sections_header",
            raw_bytes="ef00 01 01 0004 02 0000 04 0000 00 00800000",
            validity_error=[
                EOFException.ZERO_SECTION_SIZE,
                EOFException.INCOMPLETE_SECTION_NUMBER,
            ],
        ),
        Container(
            name="zero_code_sections_header_empty_type_section",
            raw_bytes="ef00 01 01 0000 02 0000 04 0000 00",
            validity_error=[
                EOFException.ZERO_SECTION_SIZE,
                EOFException.INCOMPLETE_SECTION_NUMBER,
            ],
        ),
        # The basic `no_section_terminator` cases just remove the terminator
        # and the `00` for zeroth section inputs looks like one. Error is because
        # the sections are wrongly sized.
        Container(
            name="no_section_terminator",
            header_terminator=bytes(),
            sections=[Section.Code(code=Op.STOP)],
            validity_error=[
                EOFException.INVALID_SECTION_BODIES_SIZE,
                EOFException.INVALID_FIRST_SECTION_TYPE,
            ],
        ),
        Container(
            name="no_section_terminator_1",
            header_terminator=bytes(),
            sections=[Section.Code(code=Op.STOP, custom_size=2)],
            validity_error=[
                EOFException.INVALID_SECTION_BODIES_SIZE,
                EOFException.INVALID_FIRST_SECTION_TYPE,
            ],
        ),
        Container(
            name="no_section_terminator_2",
            header_terminator=bytes(),
            sections=[Section.Code(code="0x", custom_size=3)],
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="no_section_terminator_3",
            header_terminator=bytes(),
            sections=[Section.Code(code=Op.PUSH1(0) + Op.STOP)],
            validity_error=[
                EOFException.INVALID_SECTION_BODIES_SIZE,
                EOFException.INVALID_FIRST_SECTION_TYPE,
            ],
        ),
        # The following cases just remove the terminator
        # and the `00` for zeroth section inputs looks like one. Section bodies
        # are as the size prescribes here, so the error is about the inputs of zeroth section.
        Container(
            name="no_section_terminator_section_bodies_ok_1",
            header_terminator=bytes(),
            sections=[Section.Code(code=Op.JUMPDEST + Op.STOP, custom_size=1)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="no_section_terminator_section_bodies_ok_2",
            header_terminator=bytes(),
            sections=[Section.Code(code=Op.JUMPDEST * 2 + Op.STOP, custom_size=2)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        # Here the terminator is missing but made to look like a different section
        # or arbitrary byte
        Container(
            name="no_section_terminator_nonzero",
            header_terminator=b"01",
            sections=[Section.Code(code=Op.STOP)],
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_section_terminator_nonzero_1",
            header_terminator=b"02",
            sections=[Section.Code(code=Op.STOP, custom_size=2)],
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_section_terminator_nonzero_2",
            header_terminator=b"03",
            sections=[Section.Code(code="0x", custom_size=3)],
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_section_terminator_nonzero_3",
            header_terminator=b"04",
            sections=[Section.Code(code=Op.PUSH1(0) + Op.STOP)],
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_section_terminator_nonzero_4",
            header_terminator=b"fe",
            sections=[Section.Code(code=Op.PUSH1(0) + Op.STOP)],
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="truncated_before_type_section",
            sections=[
                Section(kind=SectionKind.TYPE, data=b"", custom_size=4),
                Section.Code(code=b"", custom_size=0x01),
            ],
            expected_bytecode="ef00 01 01 0004 02 0001 0001 04 0000 00",
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="truncated_type_section_before_outputs",
            sections=[
                Section(kind=SectionKind.TYPE, data=b"\0", custom_size=4),
                Section.Code(code=b"", custom_size=0x01),
            ],
            expected_bytecode="ef00 01 01 0004 02 0001 0001 04 0000 00 00",
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="truncated_type_section_before_max_stack_height",
            sections=[
                Section(kind=SectionKind.TYPE, data=b"\0\x80", custom_size=4),
                Section.Code(code=b"", custom_size=0x01),
            ],
            expected_bytecode="ef00 01 01 0004 02 0001 0001 04 0000 00 0080",
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="truncated_type_section_truncated_max_stack_height",
            sections=[
                Section(kind=SectionKind.TYPE, data=b"\0\x80\0", custom_size=4),
                Section.Code(code=b"", custom_size=0x01),
            ],
            expected_bytecode="ef00 01 01 0004 02 0001 0001 04 0000 00 008000",
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="no_code_section_contents",
            sections=[Section.Code(code="0x", custom_size=0x01)],
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="incomplete_code_section_contents",
            sections=[
                Section.Code(code=Op.STOP, custom_size=0x02),
            ],
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="trailing_bytes_after_code_section",
            sections=[Section.Code(code=Op.PUSH1(0) + Op.STOP)],
            extra=bytes([0xDE, 0xAD, 0xBE, 0xEF]),
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="empty_code_section",
            sections=[Section.Code(code="0x")],
            # TODO the exception must be about code section EOFException.INVALID_CODE_SECTION,
            validity_error=EOFException.ZERO_SECTION_SIZE,
        ),
        Container(
            name="empty_code_section_with_non_empty_data",
            sections=[
                Section.Code(code="0x"),
                Section.Data(data="0xDEADBEEF"),
            ],
            # TODO the exception must be about code section EOFException.INVALID_CODE_SECTION,
            validity_error=EOFException.ZERO_SECTION_SIZE,
        ),
        Container(
            name="no_container_section_contents",
            sections=[
                Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
                Section(kind=SectionKind.CONTAINER, data=b"", custom_size=20),
            ],
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="no_container_section_contents_with_data",
            sections=[
                Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
                Section(kind=SectionKind.CONTAINER, data=b"", custom_size=20),
                Section.Data(b"\0" * 20),
            ],
            validity_error=EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
        ),
        Container(
            name="no_data_section_contents",
            sections=[
                Section.Code(Op.STOP),
                Section.Data(data="0x", custom_size=1),
            ],
            code="ef0001 010004 0200010001 040001 00 00800000 00",
            validity_error=EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
        ),
        Container(
            name="data_section_contents_incomplete",
            sections=[
                Section.Code(Op.STOP),
                Section.Data(data="0xAABBCC", custom_size=4),
            ],
            validity_error=EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
        ),
        Container(
            name="data_section_preceding_code_section",
            auto_data_section=False,
            auto_sort_sections=AutoSection.NONE,
            sections=[
                Section.Data(data="0xDEADBEEF"),
                Section.Code(Op.STOP),
            ],
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="data_section_without_code_section",
            sections=[Section.Data(data="0xDEADBEEF")],
            # TODO the actual exception should be EOFException.MISSING_CODE_HEADER
            validity_error=[EOFException.ZERO_SECTION_SIZE, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_section_terminator_3a",
            header_terminator=bytes(),
            sections=[Section.Code(code="0x030004")],
            # TODO the exception must be about terminator
            validity_error=[
                EOFException.INVALID_SECTION_BODIES_SIZE,
                EOFException.INVALID_FIRST_SECTION_TYPE,
            ],
        ),
        Container(
            name="no_section_terminator_4a",
            header_terminator=bytes(),
            sections=[
                Section.Code(Op.STOP),
                Section.Data(data="0xAABBCCDD"),
            ],
            # TODO: The error of this validation can be random.
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="trailing_bytes_after_data_section",
            extra=bytes([0xEE]),
            sections=[
                Section.Code(code=Op.PUSH1(0) + Op.STOP),
                Section.Data(data="0xAABBCCDD"),
            ],
            # TODO should be more specific exception about trailing bytes
            validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
        ),
        Container(
            name="multiple_data_sections",
            sections=[
                Section.Code(code=Op.PUSH1(0) + Op.STOP),
                Section.Data(data="0xAABBCC"),
                Section.Data(data="0xAABBCC"),
            ],
            expected_bytecode=(
                "ef00 01 01 0004 02 0001 0003 04 0003 04 0003 00 00800001 600000 AABBCC AABBCC"
            ),
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="multiple_code_headers",
            sections=[
                Section.Code(Op.JUMPF[1]),
                Section.Data(data="0xAA"),
                Section.Code(Op.STOP),
            ],
            auto_sort_sections=AutoSection.ONLY_BODY,
            expected_bytecode=(
                "ef00 01 01 0008 02 0001 0003 04 0001 02 0001 0001 00"
                "00800000 00800000 E50001 00 AA"
            ),
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="multiple_code_headers_2",
            sections=[
                Section.Code(Op.JUMPF[1]),
                Section.Code(Op.STOP),
                Section.Data(data="0xAA"),
            ],
            skip_join_concurrent_sections_in_header=True,
            expected_bytecode=(
                "ef00 01 01 0008 02 0001 0003 02 0001 0001 04 0001 00"
                "00800000 00800000 E50001 00 AA"
            ),
            validity_error=[
                EOFException.MISSING_DATA_SECTION,
                EOFException.UNEXPECTED_HEADER_KIND,
            ],
        ),
        Container(
            name="duplicated_code_header",
            sections=[
                Section.Code(Op.STOP),
                Section.Code(
                    b"",
                    custom_size=1,
                    skip_types_header_listing=True,
                    skip_types_body_listing=True,
                ),
                Section.Data(data="0xAA"),
            ],
            skip_join_concurrent_sections_in_header=True,
            expected_bytecode=(
                "ef00 01 01 0004 02 0001 0001 02 0001 0001 04 0001 00 00800000 00 AA"
            ),
            validity_error=[
                EOFException.MISSING_DATA_SECTION,
                EOFException.UNEXPECTED_HEADER_KIND,
            ],
        ),
        Container(
            name="multiple_code_and_data_sections",
            sections=[
                Section.Code(Op.JUMPF[1]),
                Section.Code(Op.STOP),
                Section.Data(data="0xAA"),
                Section.Data(data="0xAA"),
            ],
            expected_bytecode=(
                "ef00 01 01 0008 02 0002 0003 0001 04 0001 04 0001 00"
                "00800000 00800000 E50001 00 AA AA"
            ),
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="multiple_code_and_data_sections_2",
            sections=[
                Section.Code(Op.JUMPF[1]),
                Section.Code(Op.STOP),
                Section.Data(data="0xAA"),
                Section.Data(data="0xAA"),
            ],
            skip_join_concurrent_sections_in_header=True,
            expected_bytecode=(
                "ef00 01 01 0008 02 0001 0003 02 0001 0001 04 0001 04 0001 00"
                "00800000 00800000 E50001 00 AA AA"
            ),
            validity_error=[
                EOFException.MISSING_DATA_SECTION,
                EOFException.UNEXPECTED_HEADER_KIND,
            ],
        ),
        Container(
            name="multiple_container_headers",
            sections=[
                Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.EOFCREATE[1](0, 0, 0, 0) + Op.STOP),
                Section.Container(Container.Code(code=Op.INVALID)),
                Section.Data(data="0xAA"),
                Section.Container(Container.Code(code=Op.INVALID)),
            ],
            auto_sort_sections=AutoSection.ONLY_BODY,
            expected_bytecode=(
                "ef00 01 01 0004 02 0001 0015 03 0001 0014 04 0001 03 0001 0014 00"
                "00800005 6000600060006000ec00 6000600060006000ec01 00"
                "ef00 01 01 0004 02 0001 0001 04 0000 00 00800000 fe"
                "ef00 01 01 0004 02 0001 0001 04 0000 00 00800000 fe"
                "aa"
            ),
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="multiple_container_headers_2",
            sections=[
                Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.EOFCREATE[1](0, 0, 0, 0) + Op.STOP),
                Section.Container(Container.Code(code=Op.INVALID)),
                Section.Container(Container.Code(code=Op.INVALID)),
                Section.Data(data="0xAA"),
            ],
            skip_join_concurrent_sections_in_header=True,
            expected_bytecode=(
                "ef00 01 01 0004 02 0001 0015 03 0001 0014 03 0001 0014 04 0001 00"
                "00800005 6000600060006000ec00 6000600060006000ec01 00"
                "ef00 01 01 0004 02 0001 0001 04 0000 00 00800000 fe"
                "ef00 01 01 0004 02 0001 0001 04 0000 00 00800000 fe"
                "aa"
            ),
            validity_error=[
                EOFException.MISSING_DATA_SECTION,
                EOFException.UNEXPECTED_HEADER_KIND,
            ],
        ),
        Container(
            name="duplicated_container_header",
            sections=[
                Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
                Section.Container(Container.Code(code=Op.INVALID)),
                Section(kind=SectionKind.CONTAINER, data=b"", custom_size=20),
                Section.Data(data="0xAA"),
            ],
            skip_join_concurrent_sections_in_header=True,
            expected_bytecode=(
                "ef00 01 01 0004 02 0001 000b 03 0001 0014 03 0001 0014 04 0001 00"
                "00800004 6000600060006000ec00 00"
                "ef00 01 01 0004 02 0001 0001 04 0000 00 00800000 fe"
                "aa"
            ),
            validity_error=[
                EOFException.MISSING_DATA_SECTION,
                EOFException.UNEXPECTED_HEADER_KIND,
            ],
        ),
        Container(
            name="unknown_section_1",
            sections=[
                Section.Code(Op.STOP),
                Section.Data(data="0x"),
                Section(kind=VERSION_MAX_SECTION_KIND + 1, data="0x01"),
            ],
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="unknown_section_2",
            sections=[
                Section(kind=VERSION_MAX_SECTION_KIND + 1, data="0x01"),
                Section.Data(data="0x"),
                Section.Code(Op.STOP),
            ],
            # TODO the exception should be about unknown section definition
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="unknown_section_empty",
            sections=[
                Section.Code(Op.STOP),
                Section.Data(data="0x"),
                Section(kind=VERSION_MAX_SECTION_KIND + 1, data="0x"),
            ],
            validity_error=[EOFException.MISSING_TERMINATOR, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_type_section",
            sections=[
                Section.Code(code=Op.STOP),
                Section.Data("0x00"),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=[EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_type_section_2_codes",
            sections=[
                Section.Code(Op.INVALID),
                Section.Code(Op.INVALID),
            ],
            auto_type_section=AutoSection.NONE,
            auto_data_section=False,
            expected_bytecode="ef0001 020002 0001 0001 00 fefe",
            validity_error=[EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_type_section_data_section",
            sections=[
                Section.Code(Op.INVALID),
                Section.Data("0xda"),
            ],
            auto_type_section=AutoSection.NONE,
            expected_bytecode="ef0001 020001 0001 040001 00 feda",
            validity_error=[EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="no_type_section_container_section",
            sections=[
                Section.Code(Op.INVALID),
                Section.Container(
                    Container(
                        sections=[
                            Section.Code(code=Op.RETURNCONTRACT[0](0, 0)),
                            Section.Container(container=Container.Code(code=Op.STOP)),
                        ],
                    )
                ),
            ],
            auto_type_section=AutoSection.NONE,
            expected_bytecode="ef0001 020001 0001 030001 0032 040000 00 fe"
            "ef0001 010004 020001 0006 030001 0014 040000 00 00800002 60006000ee00"
            "ef0001 010004 020001 0001 040000 00 0080000000",
            validity_error=[EOFException.MISSING_TYPE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="too_many_type_sections",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x00000000"),
                Section(kind=SectionKind.TYPE, data="0x00000000"),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="too_many_type_sections_2",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x00800000"),
                Section(kind=SectionKind.TYPE, data="0x00800000"),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="empty_type_section_empty_code",
            sections=[
                Section(kind=SectionKind.TYPE),
                Section.Code(),
            ],
            expected_bytecode="ef00 01 01 0000 02 0001 0000 04 0000 00",
            validity_error=[
                EOFException.ZERO_SECTION_SIZE,
                EOFException.INVALID_SECTION_BODIES_SIZE,
            ],
        ),
        Container(
            name="empty_type_section_with_code",
            sections=[
                Section(kind=SectionKind.TYPE),
                Section.Code(Op.STOP),
            ],
            expected_bytecode="ef00 01 01 0000 02 0001 0001 04 0000 00 00",
            validity_error=[
                EOFException.ZERO_SECTION_SIZE,
                EOFException.INVALID_SECTION_BODIES_SIZE,
            ],
        ),
        Container(
            name="type_section_too_small_single_code_section_1",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x00"),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            name="type_section_too_small_single_code_section_2",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x008000"),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            name="type_section_too_big_single_code_section",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x0080000000"),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            name="type_section_too_small_multiple_code_sections_1",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x0080000000"),
                Section.Code(Op.STOP),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            name="type_section_too_small_multiple_code_sections_2",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x008000000080"),
                Section.Code(Op.STOP),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            name="type_section_too_big_multiple_code_sections",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x008000000080000000"),
                Section.Code(Op.STOP),
                Section.Code(Op.STOP),
            ],
            auto_type_section=AutoSection.NONE,
            validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
        ),
        Container(
            name="invalid_first_code_section_inputs_0x01",
            sections=[Section.Code(code=Op.POP + Op.RETF, code_inputs=1)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="invalid_first_code_section_inputs_0x80",
            sections=[Section.Code(code=Op.POP + Op.RETF, code_inputs=0x80)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="invalid_first_code_section_inputs_0xff",
            sections=[Section.Code(code=Op.POP + Op.RETF, code_inputs=0xFF)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="invalid_first_code_section_outputs_0x00",
            sections=[Section.Code(code=Op.PUSH0 + Op.RETF, code_outputs=0)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="invalid_first_code_section_outputs_0x7f",
            sections=[Section.Code(code=Op.PUSH0 + Op.RETF, code_outputs=0x7F)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="invalid_first_code_section_outputs_0x81",
            sections=[Section.Code(code=Op.PUSH0 + Op.RETF, code_outputs=0x81)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="invalid_first_code_section_outputs_0xff",
            sections=[Section.Code(code=Op.PUSH0 + Op.RETF, code_outputs=0xFF)],
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="multiple_code_section_non_zero_inputs",
            sections=[
                Section.Code(code=Op.POP + Op.RETF, code_inputs=1),
                Section.Code(Op.STOP),
            ],
            # TODO the actual exception should be EOFException.INVALID_TYPE_BODY,
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="multiple_code_section_non_zero_outputs",
            sections=[
                Section.Code(code=Op.PUSH0, code_outputs=1),
                Section.Code(Op.STOP),
            ],
            # TODO the actual exception should be EOFException.INVALID_TYPE_BODY,
            validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
        ),
        Container(
            name="data_section_before_code_with_type",
            sections=[
                Section.Data(data="0xAA"),
                Section.Code(Op.STOP),
            ],
            auto_sort_sections=AutoSection.NONE,
            validity_error=[EOFException.MISSING_CODE_HEADER, EOFException.UNEXPECTED_HEADER_KIND],
        ),
        Container(
            name="data_section_listed_in_type",
            sections=[
                Section.Data(data="0x00", force_type_listing=True),
                Section.Code(Op.STOP),
            ],
            validity_error=[
                EOFException.INVALID_TYPE_SECTION_SIZE,
                EOFException.INVALID_SECTION_BODIES_SIZE,
            ],
        ),
        Container(
            name="single_code_section_incomplete_type",
            sections=[
                Section(kind=SectionKind.TYPE, data="0x00", custom_size=2),
                Section.Code(Op.STOP),
            ],
            validity_error=[
                EOFException.INVALID_SECTION_BODIES_SIZE,
                EOFException.INVALID_TYPE_SECTION_SIZE,
            ],
        ),
        Container(
            name="code_section_input_too_large",
            sections=[
                Section.Code(
                    code=((Op.PUSH0 * (MAX_CODE_INPUTS + 1)) + Op.CALLF[1] + Op.STOP),
                    max_stack_height=(MAX_CODE_INPUTS + 1),
                ),
                Section.Code(
                    code=(Op.POP * (MAX_CODE_INPUTS + 1)) + Op.RETF,
                    code_inputs=(MAX_CODE_INPUTS + 1),
                    code_outputs=0,
                    max_stack_height=0,
                ),
            ],
            validity_error=EOFException.INPUTS_OUTPUTS_NUM_ABOVE_LIMIT,
        ),
        Container(
            name="invalid_inputs_to_non_returning_code_section_2",
            sections=[
                Section.Code(
                    code=Op.PUSH1(0) * 128 + Op.CALLF[1] + Op.STOP,
                    max_stack_height=128,
                ),
                Section.Code(
                    Op.STOP,
                    code_inputs=128,
                    code_outputs=0,
                    max_stack_height=128,
                ),
            ],
            validity_error=EOFException.INPUTS_OUTPUTS_NUM_ABOVE_LIMIT,
        ),
        Container(
            name="code_section_output_too_large",
            sections=[
                Section.Code(
                    code=(Op.CALLF[1] + Op.STOP),
                    max_stack_height=(MAX_CODE_OUTPUTS + 2),
                ),
                Section.Code(
                    code=(Op.PUSH0 * (MAX_CODE_OUTPUTS + 2)) + Op.RETF,
                    code_inputs=0,
                    code_outputs=(MAX_CODE_OUTPUTS + 2),
                    max_stack_height=(MAX_CODE_OUTPUTS + 2),
                ),
            ],
            validity_error=EOFException.INPUTS_OUTPUTS_NUM_ABOVE_LIMIT,
        ),
        Container(
            name="single_code_section_max_stack_size_too_large",
            sections=[
                Section.Code(
                    code=Op.CALLER * 1024 + Op.POP * 1024 + Op.STOP,
                    max_stack_height=1024,
                ),
            ],
            # TODO auto types section generation probably failed, the exception must be about code
            validity_error=EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT,
        ),
    ],
    ids=lambda c: c.name,
)
def test_invalid_containers(
    eof_test: EOFTestFiller,
    container: Container,
):
    """Test invalid containers."""
    assert container.validity_error is not None, "Invalid container without validity error"
    eof_test(
        container=bytes(container),
        expect_exception=container.validity_error,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) container
...fork_Osaka-eof_test-empty_container empty_container
...fork_Osaka-eof_test-single_code_section_no_data_section single_code_section_no_data_section
...fork_Osaka-eof_test-incomplete_magic incomplete_magic
...fork_Osaka-eof_test-no_version no_version
...fork_Osaka-eof_test-no_type_header no_type_header
...fork_Osaka-eof_test-no_type_section_size no_type_section_size
...fork_Osaka-eof_test-incomplete_type_section_size incomplete_type_section_size
...fork_Osaka-eof_test-no_code_header no_code_header
...fork_Osaka-eof_test-no_code_header_2 no_code_header_2
...fork_Osaka-eof_test-no_code_header_3 no_code_header_3
...fork_Osaka-eof_test-no_code_header_4 no_code_header_4
...fork_Osaka-eof_test-code_section_count_missing code_section_count_missing
...fork_Osaka-eof_test-code_section_count_incomplete code_section_count_incomplete
...fork_Osaka-eof_test-code_section_size_missing code_section_size_missing
...fork_Osaka-eof_test-code_section_size_incomplete code_section_size_incomplete
...fork_Osaka-eof_test-code_section_count_0x8000_truncated code_section_count_0x8000_truncated
...fork_Osaka-eof_test-code_section_count_0xFFFF_truncated code_section_count_0xFFFF_truncated
...fork_Osaka-eof_test-code_section_count_0x8000 code_section_count_0x8000
...fork_Osaka-eof_test-code_section_count_0xFFFF code_section_count_0xFFFF
...fork_Osaka-eof_test-code_section_size_0x8000_truncated code_section_size_0x8000_truncated
...fork_Osaka-eof_test-code_section_size_0xFFFF_truncated code_section_size_0xFFFF_truncated
...fork_Osaka-eof_test-terminator_incomplete terminator_incomplete
...fork_Osaka-eof_test-truncated_header_data_section truncated_header_data_section
...fork_Osaka-eof_test-no_data_section_size no_data_section_size
...fork_Osaka-eof_test-data_section_size_incomplete data_section_size_incomplete
...fork_Osaka-eof_test-no_container_section_count no_container_section_count
...fork_Osaka-eof_test-incomplete_container_section_count incomplete_container_section_count
...fork_Osaka-eof_test-zero_container_section_count zero_container_section_count
...fork_Osaka-eof_test-no_container_section_size no_container_section_size
...fork_Osaka-eof_test-incomplete_container_section_size incomplete_container_section_size
...fork_Osaka-eof_test-incomplete_container_section_size_2 incomplete_container_section_size_2
...fork_Osaka-eof_test-incomplete_container_section_size_3 incomplete_container_section_size_3
...fork_Osaka-eof_test-zero_size_container_section zero_size_container_section
...fork_Osaka-eof_test-truncated_header_data_section_with_container_section truncated_header_data_section_with_container_section
...fork_Osaka-eof_test-no_data_section_size_with_container_section no_data_section_size_with_container_section
...fork_Osaka-eof_test-data_section_size_incomplete_with_container_section data_section_size_incomplete_with_container_section
...fork_Osaka-eof_test-EOF1I4750_0001 EOF1I4750_0001
...fork_Osaka-eof_test-multiple_type_headers_1 multiple_type_headers_1
...fork_Osaka-eof_test-multiple_type_headers_2 multiple_type_headers_2
...fork_Osaka-eof_test-multiple_type_headers_3 multiple_type_headers_3
...fork_Osaka-eof_test-EOF1I4750_0003 EOF1I4750_0003
...fork_Osaka-eof_test-EOF1I4750_0004 EOF1I4750_0004
...fork_Osaka-eof_test-EOF1I4750_0005 EOF1I4750_0005
...fork_Osaka-eof_test-EOF1I4750_0006 EOF1I4750_0006
...fork_Osaka-eof_test-EOF1I4750_0007 EOF1I4750_0007
...fork_Osaka-eof_test-EOF1I4750_0008 EOF1I4750_0008
...fork_Osaka-eof_test-no_sections no_sections
...fork_Osaka-eof_test-no_code_section_header no_code_section_header
...fork_Osaka-eof_test-too_many_code_sections too_many_code_sections
...fork_Osaka-eof_test-zero_code_sections_header zero_code_sections_header
...fork_Osaka-eof_test-zero_code_sections_header_empty_type_section zero_code_sections_header_empty_type_section
...fork_Osaka-eof_test-no_section_terminator no_section_terminator
...fork_Osaka-eof_test-no_section_terminator_1 no_section_terminator_1
...fork_Osaka-eof_test-no_section_terminator_2 no_section_terminator_2
...fork_Osaka-eof_test-no_section_terminator_3 no_section_terminator_3
...fork_Osaka-eof_test-no_section_terminator_section_bodies_ok_1 no_section_terminator_section_bodies_ok_1
...fork_Osaka-eof_test-no_section_terminator_section_bodies_ok_2 no_section_terminator_section_bodies_ok_2
...fork_Osaka-eof_test-no_section_terminator_nonzero no_section_terminator_nonzero
...fork_Osaka-eof_test-no_section_terminator_nonzero_1 no_section_terminator_nonzero_1
...fork_Osaka-eof_test-no_section_terminator_nonzero_2 no_section_terminator_nonzero_2
...fork_Osaka-eof_test-no_section_terminator_nonzero_3 no_section_terminator_nonzero_3
...fork_Osaka-eof_test-no_section_terminator_nonzero_4 no_section_terminator_nonzero_4
...fork_Osaka-eof_test-truncated_before_type_section truncated_before_type_section
...fork_Osaka-eof_test-truncated_type_section_before_outputs truncated_type_section_before_outputs
...fork_Osaka-eof_test-truncated_type_section_before_max_stack_height truncated_type_section_before_max_stack_height
...fork_Osaka-eof_test-truncated_type_section_truncated_max_stack_height truncated_type_section_truncated_max_stack_height
...fork_Osaka-eof_test-no_code_section_contents no_code_section_contents
...fork_Osaka-eof_test-incomplete_code_section_contents incomplete_code_section_contents
...fork_Osaka-eof_test-trailing_bytes_after_code_section trailing_bytes_after_code_section
...fork_Osaka-eof_test-empty_code_section empty_code_section
...fork_Osaka-eof_test-empty_code_section_with_non_empty_data empty_code_section_with_non_empty_data
...fork_Osaka-eof_test-no_container_section_contents no_container_section_contents
...fork_Osaka-eof_test-no_container_section_contents_with_data no_container_section_contents_with_data
...fork_Osaka-eof_test-no_data_section_contents no_data_section_contents
...fork_Osaka-eof_test-data_section_contents_incomplete data_section_contents_incomplete
...fork_Osaka-eof_test-data_section_preceding_code_section data_section_preceding_code_section
...fork_Osaka-eof_test-data_section_without_code_section data_section_without_code_section
...fork_Osaka-eof_test-no_section_terminator_3a no_section_terminator_3a
...fork_Osaka-eof_test-no_section_terminator_4a no_section_terminator_4a
...fork_Osaka-eof_test-trailing_bytes_after_data_section trailing_bytes_after_data_section
...fork_Osaka-eof_test-multiple_data_sections multiple_data_sections
...fork_Osaka-eof_test-multiple_code_headers multiple_code_headers
...fork_Osaka-eof_test-multiple_code_headers_2 multiple_code_headers_2
...fork_Osaka-eof_test-duplicated_code_header duplicated_code_header
...fork_Osaka-eof_test-multiple_code_and_data_sections multiple_code_and_data_sections
...fork_Osaka-eof_test-multiple_code_and_data_sections_2 multiple_code_and_data_sections_2
...fork_Osaka-eof_test-multiple_container_headers multiple_container_headers
...fork_Osaka-eof_test-multiple_container_headers_2 multiple_container_headers_2
...fork_Osaka-eof_test-duplicated_container_header duplicated_container_header
...fork_Osaka-eof_test-unknown_section_1 unknown_section_1
...fork_Osaka-eof_test-unknown_section_2 unknown_section_2
...fork_Osaka-eof_test-unknown_section_empty unknown_section_empty
...fork_Osaka-eof_test-no_type_section no_type_section
...fork_Osaka-eof_test-no_type_section_2_codes no_type_section_2_codes
...fork_Osaka-eof_test-no_type_section_data_section no_type_section_data_section
...fork_Osaka-eof_test-no_type_section_container_section no_type_section_container_section
...fork_Osaka-eof_test-too_many_type_sections too_many_type_sections
...fork_Osaka-eof_test-too_many_type_sections_2 too_many_type_sections_2
...fork_Osaka-eof_test-empty_type_section_empty_code empty_type_section_empty_code
...fork_Osaka-eof_test-empty_type_section_with_code empty_type_section_with_code
...fork_Osaka-eof_test-type_section_too_small_single_code_section_1 type_section_too_small_single_code_section_1
...fork_Osaka-eof_test-type_section_too_small_single_code_section_2 type_section_too_small_single_code_section_2
...fork_Osaka-eof_test-type_section_too_big_single_code_section type_section_too_big_single_code_section
...fork_Osaka-eof_test-type_section_too_small_multiple_code_sections_1 type_section_too_small_multiple_code_sections_1
...fork_Osaka-eof_test-type_section_too_small_multiple_code_sections_2 type_section_too_small_multiple_code_sections_2
...fork_Osaka-eof_test-type_section_too_big_multiple_code_sections type_section_too_big_multiple_code_sections
...fork_Osaka-eof_test-invalid_first_code_section_inputs_0x01 invalid_first_code_section_inputs_0x01
...fork_Osaka-eof_test-invalid_first_code_section_inputs_0x80 invalid_first_code_section_inputs_0x80
...fork_Osaka-eof_test-invalid_first_code_section_inputs_0xff invalid_first_code_section_inputs_0xff
...fork_Osaka-eof_test-invalid_first_code_section_outputs_0x00 invalid_first_code_section_outputs_0x00
...fork_Osaka-eof_test-invalid_first_code_section_outputs_0x7f invalid_first_code_section_outputs_0x7f
...fork_Osaka-eof_test-invalid_first_code_section_outputs_0x81 invalid_first_code_section_outputs_0x81
...fork_Osaka-eof_test-invalid_first_code_section_outputs_0xff invalid_first_code_section_outputs_0xff
...fork_Osaka-eof_test-multiple_code_section_non_zero_inputs multiple_code_section_non_zero_inputs
...fork_Osaka-eof_test-multiple_code_section_non_zero_outputs multiple_code_section_non_zero_outputs
...fork_Osaka-eof_test-data_section_before_code_with_type data_section_before_code_with_type
...fork_Osaka-eof_test-data_section_listed_in_type data_section_listed_in_type
...fork_Osaka-eof_test-single_code_section_incomplete_type single_code_section_incomplete_type
...fork_Osaka-eof_test-code_section_input_too_large code_section_input_too_large
...fork_Osaka-eof_test-invalid_inputs_to_non_returning_code_section_2 invalid_inputs_to_non_returning_code_section_2
...fork_Osaka-eof_test-code_section_output_too_large code_section_output_too_large
...fork_Osaka-eof_test-single_code_section_max_stack_size_too_large single_code_section_max_stack_size_too_large