@@ -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 (bytecode{" EF0001 010008 02000200040C01 040000 00 00800000 000003FF" } + OP_CALLF +
633
+ " 0001 " + OP_STOP + 0x400 * bytecode{1 } + 0x400 * OP_POP + OP_RETF,
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,25 @@ 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
802
add_test_case (" EF0001 010004 0200010001 040000 00 00800000 E4" ,
802
803
EOFValidationError::invalid_non_returning_flag);
803
804
// Invalid with JUMPF to returning
804
805
add_test_case (
805
- " EF0001 01000c 020003000100030001 040000 00 008000000080000000000000 00 E50002 E4" ,
806
+ " EF0001 01000c 020003000300030001 040000 00 008000000080000000000000 E50001 E50002 E4" ,
806
807
EOFValidationError::invalid_non_returning_flag);
807
808
// Invalid with JUMPF to non-returning
808
- add_test_case (" EF0001 010008 02000200010003 040000 00 0080000000000000 00 E50000" ,
809
+ add_test_case (" EF0001 010008 02000200030003 040000 00 0080000000000000 E50001 E50000" ,
809
810
EOFValidationError::invalid_non_returning_flag);
810
811
// Invalid with JUMPF to returning and RETF
811
812
add_test_case (
812
- " EF0001 01000C 020003000100070001 040000 00 008000000180000100000000 00 E10001E4E50002 E4" ,
813
+ " EF0001 01000C 020003000400070001 040000 00 008000010180000100000000 5FE50001 "
814
+ " E10001E4E50002 E4" ,
813
815
EOFValidationError::invalid_non_returning_flag);
814
816
// Invalid with JUMPF to non-returning and RETF
815
- add_test_case (" EF0001 010008 02000200010007 040000 00 0080000001800001 00 E10001E4E50000" ,
817
+ add_test_case (" EF0001 010008 02000200040007 040000 00 0080000101800001 5FE50001 E10001E4E50000" ,
816
818
EOFValidationError::invalid_non_returning_flag);
817
819
818
820
// Circular JUMPF: can be both returning and non-returning
@@ -909,5 +911,19 @@ TEST_F(eof_validation, unreachable_code_sections)
909
911
// Code Section 254 calls itself instead of code section 255, leaving code section 255
910
912
// unreachable
911
913
add_test_case (code_sections_256_err_254, EOFValidationError::unreachable_code_sections);
914
+
915
+ // Code Section 0 calls section 1, which calls itself, leaving section
916
+ // 2 unreachable
917
+ add_test_case (eof_bytecode (OP_STOP).code (jumpf (1 ), 0 , 0x80 , 0 ).code (jumpf (2 ), 0 , 0x80 , 0 ),
918
+ EOFValidationError::unreachable_code_sections);
919
+
920
+ // Code Section 0 calls section 1, which calls section 2, section 3 and
921
+ // 4 call each other but are not reachable from section 0
922
+ add_test_case (eof_bytecode (jumpf (1 ))
923
+ .code (jumpf (2 ), 0 , 0x80 , 0 )
924
+ .code (OP_INVALID, 0 , 0x80 , 0 )
925
+ .code (jumpf (4 ), 0 , 0x80 , 0 )
926
+ .code (jumpf (3 ), 0 , 0x80 , 0 ),
927
+ EOFValidationError::unreachable_code_sections);
912
928
}
913
929
}
0 commit comments