diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs index 8ff3fcae18..a32317c83e 100644 --- a/packages/vm/src/environment.rs +++ b/packages/vm/src/environment.rs @@ -153,9 +153,9 @@ impl Environment { }) } - pub fn set_global(&mut self, a: Global, b: Global) { - self.global_remaining_points = Some(a); - self.global_points_exhausted = Some(b) + pub fn set_global(&mut self, remain: Global, exhausted: Global) { + self.global_remaining_points = Some(remain); + self.global_points_exhausted = Some(exhausted) } pub fn debug_handler(&self) -> Option>> { @@ -503,7 +503,7 @@ mod tests { Store, Box, ) { - let env = Environment::new(MockApi::default(), gas_limit); + let mut env = Environment::new(MockApi::default(), gas_limit); let (engine, module) = compile(CONTRACT, &[]).unwrap(); let mut store = make_store_with_engine(engine, TESTING_MEMORY_LIMIT); @@ -533,6 +533,16 @@ mod tests { let instance_ptr = NonNull::from(instance.as_ref()); env.set_wasmer_instance(Some(instance_ptr)); env.set_gas_left(&mut store, gas_limit); + let remaining_points = instance + .exports + .get_global("wasmer_metering_remaining_points"); + let points_exhausted = instance + .exports + .get_global("wasmer_metering_points_exhausted"); + env.set_global( + remaining_points.unwrap().clone(), + points_exhausted.unwrap().clone(), + ); (env, store, instance) } diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index d9769d7861..68d9981c8f 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -663,6 +663,16 @@ mod tests { env.set_wasmer_instance(Some(instance_ptr)); env.set_gas_left(&mut store, gas_limit); + let remaining_points = wasmer_instance + .exports + .get_global("wasmer_metering_remaining_points"); + let points_exhausted = wasmer_instance + .exports + .get_global("wasmer_metering_points_exhausted"); + env.set_global( + remaining_points.unwrap().clone(), + points_exhausted.unwrap().clone(), + ); env.set_storage_readonly(false); }