Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
scf0220 committed Jul 11, 2023
1 parent 0331829 commit 2ea25fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/vm/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ impl<A: BackendApi, S: Storage, Q: Querier> Environment<A, S, Q> {
})
}

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<Rc<RefCell<DebugHandlerFn>>> {
Expand Down Expand Up @@ -503,7 +503,7 @@ mod tests {
Store,
Box<WasmerInstance>,
) {
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);
Expand Down Expand Up @@ -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)
}
Expand Down
10 changes: 10 additions & 0 deletions packages/vm/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2ea25fd

Please sign in to comment.