@@ -629,8 +629,8 @@ TEST_F(eof_validation, max_stack_height)
629
629
0x400 * OP_POP + OP_STOP + OP_RETF,
630
630
EOFValidationError::max_stack_height_above_limit);
631
631
632
- add_test_case (bytecode{ " EF0001 010008 02000200010C01 040000 00 00800000 000003FF " } + OP_STOP +
633
- 0x400 * bytecode{1 } + 0x400 * OP_POP + OP_RETF,
632
+ add_test_case (eof_bytecode ( callf ( 1 ) + OP_STOP, 0 )
633
+ . code ( 0x400 * bytecode{1 } + 0x400 * OP_POP + OP_RETF, 0 , 0 , 1023 ) ,
634
634
EOFValidationError::invalid_max_stack_height);
635
635
636
636
add_test_case (" EF0001 010008 0200020C010001 040000 00 008003FF 00000000" + 0x400 * bytecode{1 } +
@@ -796,23 +796,24 @@ TEST_F(eof_validation, non_returning_status)
796
796
EOFValidationError::success);
797
797
798
798
// Invalid with RETF
799
- add_test_case (" EF0001 010008 02000200010001 040000 00 0080000000800000 00 E4 " ,
799
+ add_test_case (eof_bytecode ( jumpf ( 1 )). code (OP_RETF, 0 , 0x80 , 0 ) ,
800
800
EOFValidationError::invalid_non_returning_flag);
801
801
add_test_case (" EF0001 010004 0200010001 040000 00 00800000 E4" ,
802
802
EOFValidationError::invalid_non_returning_flag);
803
803
// Invalid with JUMPF to returning
804
804
add_test_case (
805
- " EF0001 01000c 020003000100030001 040000 00 008000000080000000000000 00 E50002 E4" ,
805
+ " EF0001 01000c 020003000300030001 040000 00 008000000080000000000000 E50001 E50002 E4" ,
806
806
EOFValidationError::invalid_non_returning_flag);
807
807
// Invalid with JUMPF to non-returning
808
- add_test_case (" EF0001 010008 02000200010003 040000 00 0080000000000000 00 E50000" ,
808
+ add_test_case (" EF0001 010008 02000200030003 040000 00 0080000000000000 E50001 E50000" ,
809
809
EOFValidationError::invalid_non_returning_flag);
810
810
// Invalid with JUMPF to returning and RETF
811
811
add_test_case (
812
- " EF0001 01000C 020003000100070001 040000 00 008000000180000100000000 00 E10001E4E50002 E4" ,
812
+ " EF0001 01000C 020003000400070001 040000 00 008000010180000100000000 5FE50001 "
813
+ " E10001E4E50002 E4" ,
813
814
EOFValidationError::invalid_non_returning_flag);
814
815
// Invalid with JUMPF to non-returning and RETF
815
- add_test_case (" EF0001 010008 02000200010007 040000 00 0080000001800001 00 E10001E4E50000" ,
816
+ add_test_case (" EF0001 010008 02000200040007 040000 00 0080000101800001 5FE50001 E10001E4E50000" ,
816
817
EOFValidationError::invalid_non_returning_flag);
817
818
818
819
// Circular JUMPF: can be both returning and non-returning
@@ -909,5 +910,19 @@ TEST_F(eof_validation, unreachable_code_sections)
909
910
// Code Section 254 calls itself instead of code section 255, leaving code section 255
910
911
// unreachable
911
912
add_test_case (code_sections_256_err_254, EOFValidationError::unreachable_code_sections);
913
+
914
+ // Code Section 0 calls section 1, which calls itself, leaving section
915
+ // 2 unreachable
916
+ add_test_case (eof_bytecode (jumpf (1 )).code (jumpf (1 ), 0 , 0x80 , 0 ).code (jumpf (2 ), 0 , 0x80 , 0 ),
917
+ EOFValidationError::unreachable_code_sections);
918
+
919
+ // Code Section 0 calls section 1, which calls section 2, section 3 and
920
+ // 4 call each other but are not reachable from section 0
921
+ add_test_case (eof_bytecode (jumpf (1 ))
922
+ .code (jumpf (2 ), 0 , 0x80 , 0 )
923
+ .code (OP_INVALID, 0 , 0x80 , 0 )
924
+ .code (jumpf (4 ), 0 , 0x80 , 0 )
925
+ .code (jumpf (3 ), 0 , 0x80 , 0 ),
926
+ EOFValidationError::unreachable_code_sections);
912
927
}
913
928
}
0 commit comments