mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Adds a test to ensure that we clear the heap between calls into runtime (#4903)
* Adds a test to ensure that we clear the heap between calls into runtime The tests shows that we currently not clearing the heap in wasmtime. For now we don't run the test for wasmtime. * Fix compilation
This commit is contained in:
@@ -565,3 +565,26 @@ fn restoration_of_globals(wasm_method: WasmExecutionMethod) {
|
||||
let res = instance.call("allocates_huge_stack_array", &false.encode());
|
||||
assert!(res.is_ok());
|
||||
}
|
||||
|
||||
#[test_case(WasmExecutionMethod::Interpreted)]
|
||||
fn heap_is_reset_between_calls(wasm_method: WasmExecutionMethod) {
|
||||
let mut instance = crate::wasm_runtime::create_wasm_runtime_with_code(
|
||||
wasm_method,
|
||||
1024,
|
||||
&WASM_BINARY[..],
|
||||
HostFunctions::host_functions(),
|
||||
true,
|
||||
).expect("Creates instance");
|
||||
|
||||
let heap_base = instance.get_global_val("__heap_base")
|
||||
.expect("`__heap_base` is valid")
|
||||
.expect("`__heap_base` exists")
|
||||
.as_i32()
|
||||
.expect("`__heap_base` is an `i32`");
|
||||
|
||||
let params = (heap_base as u32, 512u32 * 64 * 1024).encode();
|
||||
instance.call("check_and_set_in_heap", ¶ms).unwrap();
|
||||
|
||||
// Cal it a second time to check that the heap was freed.
|
||||
instance.call("check_and_set_in_heap", ¶ms).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user