Tweak C API for fuel

* Ensure `store` is in the function names
* Don't abort the process on `add_fuel` when fuel isn't configured
* Allow learning about failure in both `add_fuel` and `fuel_consumed`
This commit is contained in:
Alex Crichton
2021-02-09 07:16:59 -08:00
parent 5b55ba8053
commit de27fbe20f
5 changed files with 37 additions and 17 deletions

View File

@@ -51,7 +51,7 @@ fn fuel_consumed(wasm: &[u8]) -> u64 {
let engine = Engine::new(&config);
let module = Module::new(&engine, wasm).unwrap();
let store = Store::new(&engine);
store.add_fuel(u64::max_value());
store.add_fuel(u64::max_value()).unwrap();
drop(Instance::new(&store, &module, &[]));
store.fuel_consumed().unwrap()
}
@@ -113,7 +113,7 @@ fn iloop() {
let engine = Engine::new(&config);
let module = Module::new(&engine, wat).unwrap();
let store = Store::new(&engine);
store.add_fuel(10_000);
store.add_fuel(10_000).unwrap();
let error = Instance::new(&store, &module, &[]).err().unwrap();
assert!(
error.to_string().contains("all fuel consumed"),