Skip to content

Commit

Permalink
Fix bad test in near-vm-logic (#1565)
Browse files Browse the repository at this point in the history
* Fix bad test in near-vm-logic
* Merge refs/heads/staging into bad_test
  • Loading branch information
mikhailOK authored and nearprotocol-bulldozer[bot] committed Oct 25, 2019
1 parent 61248e3 commit ed8108e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions runtime/near-vm-logic/tests/test_miscs.rs
Expand Up @@ -146,21 +146,23 @@ fn test_valid_log_utf16_max_log_len_not_even() {
let mut memory = MockedMemory::default();
let mut logic = VMLogic::new(&mut ext, context.clone(), &config, &promise_results, &mut memory);
let string = "ab";
let mut utf16_bytes: Vec<u8> = vec![0u8; 0];
let mut utf16_bytes: Vec<u8> = Vec::new();
for u16_ in string.encode_utf16() {
utf16_bytes.push(u16_ as u8);
utf16_bytes.push((u16_ >> 8) as u8);
}
utf16_bytes.extend_from_slice(&[0, 0]);
logic.log_utf16(std::u64::MAX, utf16_bytes.as_ptr() as _).expect("Valid utf-16 string_bytes");
assert_eq!(logic.outcome().logs[0], format!("LOG: {}", string));

let mut logic = VMLogic::new(&mut ext, context, &config, &promise_results, &mut memory);
let string = "abc";
let mut utf16_bytes: Vec<u8> = vec![0u8; 0];
let mut utf16_bytes: Vec<u8> = Vec::new();
for u16_ in string.encode_utf16() {
utf16_bytes.push(u16_ as u8);
utf16_bytes.push((u16_ >> 8) as u8);
}
utf16_bytes.extend_from_slice(&[0, 0]);
assert_eq!(
logic.log_utf16(std::u64::MAX, utf16_bytes.as_ptr() as _),
Err(HostError::BadUTF16.into())
Expand Down

0 comments on commit ed8108e

Please sign in to comment.