Skip to content

Commit 5499319

Browse files
committed
tests for LdConst instruction
1 parent 88a9273 commit 5499319

File tree

1 file changed

+25
-3
lines changed
  • crates/move-bytecode-verifier/src/type_safety_tests

1 file changed

+25
-3
lines changed

crates/move-bytecode-verifier/src/type_safety_tests/mod.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ use move_binary_format::file_format::{
44
FunctionDefinitionIndex, empty_module
55
};
66

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+
1016
use move_bytecode_verifier_meter::dummy::DummyMeter;
1117
use crate::absint::FunctionContext;
18+
use crate::constants;
1219
use crate::type_safety;
1320

1421

@@ -609,3 +616,18 @@ fn test_ld_true_false_ok() {
609616
}
610617
}
611618

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

Comments
 (0)