mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-12 06:21:40 +00:00
Fix basics tests
This commit is contained in:
@ -4,8 +4,6 @@ extern crate parity_wasm;
|
||||
|
||||
use std::env::args;
|
||||
|
||||
use parity_wasm::ModuleInstanceInterface;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = args().collect();
|
||||
if args.len() != 3 {
|
||||
@ -15,7 +13,7 @@ fn main() {
|
||||
}
|
||||
|
||||
// Intrepreter initialization.
|
||||
let program = parity_wasm::ProgramInstance::new();
|
||||
let mut program = parity_wasm::ProgramInstance::new();
|
||||
|
||||
// Here we load module using dedicated for this purpose
|
||||
// `deserialize_file` function (which works only with modules)
|
||||
@ -26,11 +24,11 @@ fn main() {
|
||||
// - a module declaration
|
||||
// - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
|
||||
// This test shows how to implement native module https://github.com/NikVolf/parity-wasm/blob/master/src/interpreter/tests/basics.rs#L197
|
||||
let module = program.add_module("main", module, None).expect("Failed to initialize module");
|
||||
let module = program.add_module("main", module, &mut ()).expect("Failed to initialize module");
|
||||
|
||||
// The argument should be parsable as a valid integer
|
||||
let argument: i32 = args[2].parse().expect("Integer argument required");
|
||||
|
||||
// "_call" export of function to be executed with an i32 argument and prints the result of execution
|
||||
println!("Result: {:?}", module.execute_export("_call", vec![parity_wasm::RuntimeValue::I32(argument)].into()));
|
||||
println!("Result: {:?}", program.invoke_export("main", "_call", vec![parity_wasm::RuntimeValue::I32(argument)], &mut ()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user