mirror of
https://github.com/fluencelabs/marine.git
synced 2025-03-15 14:00:50 +00:00
* wip * WIP * WIP * compiles, async mrepl works * add Send * Updating marine-js * FuncGetter compiles * wow it compiles * marine-js compiles but does not work * marine-js tests almost pass * marine-runtime and marine-core tests pass * fmt * epoch interruption works in mrepl * WIP: switching from async_trait to box_future * move from async_trait to BoxFuture * self-review fixes * self-review fixes * merge memory limits * pr fixes * pr fixes * pr fixes * pr fixes * update cargo lock * use published interface-types * remove patch deps * fix factory and make AppService generic * fix marine-js * try locking deps * add debug prints to workflow * fix workflow * update workflow * make marine-js bindings patcher update all __wbg_adapter_* functions * remove debug prints from workflows * self-review fixes * self-review fixes * self-review fixes * final fixes * fix mrepl * fix pr comments, fmt and clippy * fix Cargo.toml and Cargo.lock after merge * test fixes after merge * update rust toolchain to match one in no * fixes for nox integration * reexport MError * update js bindings * fix warning * fmt
75 lines
2.6 KiB
Rust
75 lines
2.6 KiB
Rust
/*
|
|
* Copyright 2020 Fluence Labs Limited
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
use marine_core::MarineCore;
|
|
use marine_core::MarineCoreConfig;
|
|
use marine_core::IValue;
|
|
use marine_wasm_backend_traits::WasmBackend;
|
|
use marine_wasmtime_backend::WasmtimeWasmBackend;
|
|
|
|
#[tokio::test]
|
|
pub async fn records() {
|
|
let effector_wasm_bytes = std::fs::read("../examples/records/artifacts/records_effector.wasm")
|
|
.expect("../examples/records/artifacts/records_effector.wasm should presence");
|
|
|
|
let pure_wasm_bytes = std::fs::read("../examples/records/artifacts/records_pure.wasm")
|
|
.expect("../examples/records/artifacts/records_pure.wasm should presence");
|
|
|
|
let backend = WasmtimeWasmBackend::new_async().unwrap();
|
|
let mut marine_core = MarineCore::new(MarineCoreConfig::new(backend, None)).unwrap();
|
|
let load_result = marine_core
|
|
.load_module("pure", &pure_wasm_bytes, <_>::default())
|
|
.await;
|
|
assert!(load_result.is_err());
|
|
|
|
marine_core
|
|
.load_module("records_effector", &effector_wasm_bytes, <_>::default())
|
|
.await
|
|
.unwrap_or_else(|e| panic!("can't load a module into Marine: {:?}", e));
|
|
|
|
marine_core
|
|
.load_module("records_pure", &pure_wasm_bytes, <_>::default())
|
|
.await
|
|
.unwrap_or_else(|e| panic!("can't load a module into Marine: {:?}", e));
|
|
|
|
let result = marine_core
|
|
.call_async("records_pure", "invoke", &[])
|
|
.await
|
|
.unwrap_or_else(|e| panic!("can't invoke pure: {:?}", e));
|
|
|
|
assert_eq!(
|
|
result,
|
|
vec![IValue::Record(
|
|
wasmer_it::NEVec::new(vec![
|
|
IValue::Boolean(true),
|
|
IValue::S8(1),
|
|
IValue::S16(2),
|
|
IValue::S32(3),
|
|
IValue::S64(4),
|
|
IValue::U8(5),
|
|
IValue::U16(6),
|
|
IValue::U32(7),
|
|
IValue::U64(8),
|
|
IValue::F32(9.0),
|
|
IValue::F64(10.0),
|
|
IValue::String(String::from("field_11")),
|
|
IValue::ByteArray(vec![0x13, 0x37])
|
|
])
|
|
.unwrap()
|
|
)]
|
|
);
|
|
}
|