mirror of
https://github.com/fluencelabs/aquavm
synced 2025-06-27 13:41:32 +00:00
chore(testing-framework)!: restore WASM test executor (#609)
* 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`.
This commit is contained in:
@ -25,6 +25,7 @@ use std::path::PathBuf;
|
||||
// 10 Mb
|
||||
const AVM_MAX_HEAP_SIZE: u64 = 10 * 1024 * 1024;
|
||||
const AIR_WASM_PATH: &str = "../target/wasm32-wasi/debug/air_interpreter_server.wasm";
|
||||
const RELEASE_AIR_WASM_PATH: &str = "../target/wasm32-wasi/release/air_interpreter_server.wasm";
|
||||
|
||||
pub struct WasmAirRunner {
|
||||
current_peer_id: String,
|
||||
@ -92,3 +93,58 @@ impl AirRunner for WasmAirRunner {
|
||||
)?)
|
||||
}
|
||||
}
|
||||
|
||||
/// WASM runner that runs release build form benchmarking.
|
||||
pub struct ReleaseWasmAirRunner {
|
||||
current_peer_id: String,
|
||||
// these instances are not cached, as benches create relatively small number of instances
|
||||
runner: AVMRunner,
|
||||
}
|
||||
|
||||
impl AirRunner for ReleaseWasmAirRunner {
|
||||
fn new(current_peer_id: impl Into<String>) -> Self {
|
||||
let logging_mask = i32::MAX;
|
||||
|
||||
let runner = AVMRunner::new(
|
||||
PathBuf::from(RELEASE_AIR_WASM_PATH),
|
||||
Some(AVM_MAX_HEAP_SIZE),
|
||||
logging_mask,
|
||||
)
|
||||
.expect("vm should be created");
|
||||
|
||||
Self {
|
||||
current_peer_id: current_peer_id.into(),
|
||||
runner,
|
||||
}
|
||||
}
|
||||
|
||||
fn call(
|
||||
&mut self,
|
||||
air: impl Into<String>,
|
||||
prev_data: impl Into<Vec<u8>>,
|
||||
data: impl Into<Vec<u8>>,
|
||||
init_peer_id: impl Into<String>,
|
||||
timestamp: u64,
|
||||
ttl: u32,
|
||||
override_current_peer_id: Option<String>,
|
||||
call_results: avm_server::CallResults,
|
||||
keypair: &KeyPair,
|
||||
particle_id: String,
|
||||
) -> Result<RawAVMOutcome, Box<dyn std::error::Error>> {
|
||||
let current_peer_id =
|
||||
override_current_peer_id.unwrap_or_else(|| self.current_peer_id.clone());
|
||||
|
||||
Ok(self.runner.call(
|
||||
air,
|
||||
prev_data,
|
||||
data,
|
||||
init_peer_id,
|
||||
timestamp,
|
||||
ttl,
|
||||
current_peer_id,
|
||||
call_results,
|
||||
keypair,
|
||||
particle_id,
|
||||
)?)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user