()
| 408 | #[tokio::test] |
| 409 | #[cfg_attr(miri, ignore)] |
| 410 | async fn run_wasm_in_call_async() -> Result<()> { |
| 411 | _ = env_logger::try_init(); |
| 412 | |
| 413 | let mut config = Config::new(); |
| 414 | config.wasm_component_model_async(true); |
| 415 | let engine = Engine::new(&config)?; |
| 416 | |
| 417 | let a = Component::new( |
| 418 | &engine, |
| 419 | r#" |
| 420 | (component |
| 421 | (type $t (func async)) |
| 422 | (import "a" (func $f (type $t))) |
| 423 | (core func $f (canon lower (func $f))) |
| 424 | (core module $a |
| 425 | (import "" "f" (func $f)) |
| 426 | (func (export "run") call $f) |
| 427 | ) |
| 428 | (core instance $a (instantiate $a |
| 429 | (with "" (instance (export "f" (func $f)))) |
| 430 | )) |
| 431 | (func (export "run") (type $t) |
| 432 | (canon lift (core func $a "run"))) |
| 433 | ) |
| 434 | "#, |
| 435 | )?; |
| 436 | let b = Component::new( |
| 437 | &engine, |
| 438 | r#" |
| 439 | (component |
| 440 | (type $t (func async)) |
| 441 | (core module $a |
| 442 | (func (export "run")) |
| 443 | ) |
| 444 | (core instance $a (instantiate $a)) |
| 445 | (func (export "run") (type $t) |
| 446 | (canon lift (core func $a "run"))) |
| 447 | ) |
| 448 | "#, |
| 449 | )?; |
| 450 | |
| 451 | type State = Option<Instance>; |
| 452 | |
| 453 | let mut linker = Linker::new(&engine); |
| 454 | linker |
| 455 | .root() |
| 456 | .func_wrap_concurrent("a", |accessor: &Accessor<State>, (): ()| { |
| 457 | Box::pin(async move { |
| 458 | let func = accessor.with(|mut access| { |
| 459 | access |
| 460 | .get() |
| 461 | .unwrap() |
| 462 | .get_typed_func::<(), ()>(&mut access, "run") |
| 463 | })?; |
| 464 | func.call_concurrent(accessor, ()).await?; |
| 465 | Ok(()) |
| 466 | }) |
| 467 | })?; |
nothing calls this directly
no test coverage detected