@@ -4,11 +4,18 @@ use move_binary_format::file_format::{
4
4
FunctionDefinitionIndex , empty_module
5
5
} ;
6
6
7
- use move_core_types:: u256:: U256 ;
8
- use move_core_types:: vm_status:: StatusCode ;
9
- use move_binary_format:: CompiledModule ;
7
+ use move_core_types:: {
8
+ u256:: U256 , vm_status:: StatusCode ,
9
+ } ;
10
+
11
+ use move_binary_format:: {
12
+ CompiledModule ,
13
+ file_format:: { ConstantPoolIndex , Constant , SignatureToken } ,
14
+ } ;
15
+
10
16
use move_bytecode_verifier_meter:: dummy:: DummyMeter ;
11
17
use crate :: absint:: FunctionContext ;
18
+ use crate :: constants;
12
19
use crate :: type_safety;
13
20
14
21
@@ -609,3 +616,18 @@ fn test_ld_true_false_ok() {
609
616
}
610
617
}
611
618
619
+
620
+ #[ test]
621
+ fn test_ld_const_ok ( ) {
622
+ let code = vec ! [ Bytecode :: LdConst ( ConstantPoolIndex ( 0 ) ) ] ;
623
+ let constant = Constant {
624
+ type_ : SignatureToken :: U32 ,
625
+ data : vec ! [ 42 , 15 , 17 , 51 ] ,
626
+ } ;
627
+ let mut module: CompiledModule = make_module ( code) ;
628
+ module. constant_pool . push ( constant) ;
629
+ assert ! ( constants:: verify_module( & module) . is_ok( ) ) ;
630
+ let fun_context = get_fun_context ( & module) ;
631
+ let result = type_safety:: verify ( & module, & fun_context, & mut DummyMeter ) ;
632
+ assert ! ( result. is_ok( ) ) ;
633
+ }
0 commit comments