mirror of
https://github.com/fluencelabs/aquavm
synced 2025-03-28 02:11:03 +00:00
* chore(testing-framework)!: fix WASM test runner Native mode was used before because some package used native runner for its tests. This PR allows to explicitly select test runner for tests. Many testing-framework types are now parametrized with a runner type with almost compatible defaults. * chore(testing-framework): Add `ReleaseWasmAirRunner` * chore(testing-framework)!: Rename `AirScriptExecutor::simple` to `AirScriptExecutor::from_annotated`.
30 lines
904 B
Rust
30 lines
904 B
Rust
use air_test_utils::prelude::*;
|
|
|
|
use criterion::criterion_group;
|
|
use criterion::criterion_main;
|
|
use criterion::Criterion;
|
|
|
|
use std::cell::RefCell;
|
|
|
|
thread_local!(static VM: RefCell<TestRunner<ReleaseWasmAirRunner>> = RefCell::new(
|
|
create_custom_avm(unit_call_service(), "test_peer_id"))
|
|
);
|
|
thread_local!(static SCRIPT: String = String::from(
|
|
r#"
|
|
(call "test_peer_id" ("local_service_id" "local_fn_name") [] result_name)
|
|
"#,
|
|
)
|
|
);
|
|
|
|
fn current_peer_id_call() -> Result<RawAVMOutcome, String> {
|
|
let run_parameters = TestRunParameters::new("test_peer_id", 0, 1, "");
|
|
VM.with(|vm| SCRIPT.with(|script| vm.borrow_mut().call(script, "", "", run_parameters)))
|
|
}
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
|
c.bench_function("current_peer_id_call", move |b| b.iter(current_peer_id_call));
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|