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

Function run

tests/all/fuel.rs:29–49  ·  view source on GitHub ↗
(config: &mut Config)

Source from the content-addressed store, hash-verified

27#[wasmtime_test(wasm_features(bulk_memory, reference_types, gc))]
28#[cfg_attr(miri, ignore)]
29fn run(config: &mut Config) -> Result<()> {
30 config.consume_fuel(true);
31 let test = std::fs::read_to_string("tests/all/fuel.wast")?;
32 let buf = ParseBuffer::new(&test)?;
33 let mut wast = parser::parse::<FuelWast<'_>>(&buf)?;
34 for (span, fuel, module) in wast.assertions.iter_mut() {
35 let consumed = fuel_consumed(&config, &module.encode()?)?;
36 if consumed == *fuel {
37 continue;
38 }
39 let (line, col) = span.linecol_in(&test);
40 panic!(
41 "tests/all/fuel.wast:{}:{} - expected {} fuel, found {}",
42 line + 1,
43 col + 1,
44 fuel,
45 consumed
46 );
47 }
48 Ok(())
49}
50
51fn fuel_consumed(config: &Config, wasm: &[u8]) -> Result<u64> {
52 let engine = Engine::new(&config)?;

Callers 4

trappingFunction · 0.70
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50

Calls 7

read_to_stringFunction · 0.85
fuel_consumedFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
consume_fuelMethod · 0.45
iter_mutMethod · 0.45
encodeMethod · 0.45

Tested by 1

trappingFunction · 0.56