Skip to content

Commit

Permalink
Add a test for preparation of multiple memories (near#5459)
Browse files Browse the repository at this point in the history
Our preparation/sanitization pass assumes a single memory only so we
better make sure modules with only 1 memory are supported.

If we did in fact enable `multiple_memories` then the preparation code for
the memories would work incorrectly.
  • Loading branch information
nagisa authored Nov 25, 2021
1 parent 240fe63 commit f4f51e7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions runtime/near-vm-runner/src/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,26 @@ mod tests {
assert_matches!(r, Ok(_));
}

#[test]
fn multiple_valid_memory_are_disabled() {
// Our preparation and sanitization pass assumes a single memory, so we should fail when
// there are multiple specified.
let r = parse_and_prepare_wat(
r#"(module
(import "env" "memory" (memory 1 2048))
(import "env" "memory" (memory 1 2048))
)"#,
);
assert_matches!(r, Err(_));
let r = parse_and_prepare_wat(
r#"(module
(import "env" "memory" (memory 1 2048))
(memory 1)
)"#,
);
assert_matches!(r, Err(_));
}

#[test]
fn imports() {
// nothing can be imported from non-"env" module for now.
Expand Down

0 comments on commit f4f51e7

Please sign in to comment.