mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
Catch panics on the FFI boundary between the runtime and the host for wasmtime (#11189)
* Catch panics on the FFI boundary between the runtime and the host for `wasmtime` * Use an already existing test runtime function * Merge the tests together
This commit is contained in:
@@ -466,13 +466,24 @@ fn should_trap_when_heap_exhausted(wasm_method: WasmExecutionMethod) {
|
||||
RuntimeBlob::uncompress_if_needed(wasm_binary_unwrap()).unwrap(),
|
||||
&mut ext.ext(),
|
||||
true,
|
||||
"test_exhaust_heap",
|
||||
&[0],
|
||||
"test_allocate_vec",
|
||||
&16777216_u32.encode(),
|
||||
)
|
||||
.map_err(|e| e.to_string())
|
||||
.unwrap_err();
|
||||
|
||||
assert!(err.contains("Allocator ran out of space"));
|
||||
match err {
|
||||
#[cfg(feature = "wasmtime")]
|
||||
Error::AbortedDueToTrap(error) if wasm_method == WasmExecutionMethod::Compiled => {
|
||||
assert_eq!(
|
||||
error.message,
|
||||
r#"host code panicked while being called by the runtime: Failed to allocate memory: "Allocator ran out of space""#
|
||||
);
|
||||
},
|
||||
Error::RuntimePanicked(error) if wasm_method == WasmExecutionMethod::Interpreted => {
|
||||
assert_eq!(error, r#"Failed to allocate memory: "Allocator ran out of space""#);
|
||||
},
|
||||
error => panic!("unexpected error: {:?}", error),
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_test_runtime(wasm_method: WasmExecutionMethod, pages: u64) -> Arc<dyn WasmModule> {
|
||||
|
||||
Reference in New Issue
Block a user