Skip to content

Commit

Permalink
Add no memory limits runtime store test
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolacy committed Jan 10, 2021
1 parent 78fb11d commit fc74ff2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/vm/src/wasm_backend/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ mod tests {
module.serialize().unwrap()
};

// No limit
let store = make_runtime_store(Size(0));
let module = unsafe { Module::deserialize(&store, &serialized) }.unwrap();
let module_memory = module.info().memories.last().unwrap();
assert_eq!(module_memory.minimum, Pages(4));
assert_eq!(module_memory.maximum, None);
let instance = Instance::new(&module, &ImportObject::new()).unwrap();
let instance_memory: Memory = instance
.exports
.iter()
.memories()
.map(|pair| pair.1.clone())
.next()
.unwrap();
assert_eq!(instance_memory.ty().minimum, Pages(4));
assert_eq!(instance_memory.ty().maximum, None);

// Instantiate with limit
let store = make_runtime_store(Size::kibi(23 * 64));
let module = unsafe { Module::deserialize(&store, &serialized) }.unwrap();
Expand Down

0 comments on commit fc74ff2

Please sign in to comment.