MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / iloop_with_fuel

Function iloop_with_fuel

tests/all/async_functions.rs:296–316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

294#[tokio::test]
295#[cfg_attr(miri, ignore)]
296async fn iloop_with_fuel() {
297 let engine = Engine::new(Config::new().consume_fuel(true)).unwrap();
298 let mut store = Store::new(&engine, ());
299 store.set_fuel(10_000).unwrap();
300 store.fuel_async_yield_interval(Some(100)).unwrap();
301 let module = Module::new(
302 &engine,
303 "
304 (module
305 (func (loop br 0))
306 (start 0)
307 )
308 ",
309 )
310 .unwrap();
311 let instance = Instance::new_async(&mut store, &module, &[]);
312
313 // This should yield a bunch of times but eventually finish
314 let (_, pending) = CountPending::new(Box::pin(instance)).await;
315 assert_eq!(pending, 99);
316}
317
318#[tokio::test]
319#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 5

newFunction · 0.50
unwrapMethod · 0.45
consume_fuelMethod · 0.45
set_fuelMethod · 0.45

Tested by

no test coverage detected