Skip to content

Commit 2ea25fd

Browse files
committed
fix test
1 parent 0331829 commit 2ea25fd

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

packages/vm/src/environment.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ impl<A: BackendApi, S: Storage, Q: Querier> Environment<A, S, Q> {
153153
})
154154
}
155155

156-
pub fn set_global(&mut self, a: Global, b: Global) {
157-
self.global_remaining_points = Some(a);
158-
self.global_points_exhausted = Some(b)
156+
pub fn set_global(&mut self, remain: Global, exhausted: Global) {
157+
self.global_remaining_points = Some(remain);
158+
self.global_points_exhausted = Some(exhausted)
159159
}
160160

161161
pub fn debug_handler(&self) -> Option<Rc<RefCell<DebugHandlerFn>>> {
@@ -503,7 +503,7 @@ mod tests {
503503
Store,
504504
Box<WasmerInstance>,
505505
) {
506-
let env = Environment::new(MockApi::default(), gas_limit);
506+
let mut env = Environment::new(MockApi::default(), gas_limit);
507507

508508
let (engine, module) = compile(CONTRACT, &[]).unwrap();
509509
let mut store = make_store_with_engine(engine, TESTING_MEMORY_LIMIT);
@@ -533,6 +533,16 @@ mod tests {
533533
let instance_ptr = NonNull::from(instance.as_ref());
534534
env.set_wasmer_instance(Some(instance_ptr));
535535
env.set_gas_left(&mut store, gas_limit);
536+
let remaining_points = instance
537+
.exports
538+
.get_global("wasmer_metering_remaining_points");
539+
let points_exhausted = instance
540+
.exports
541+
.get_global("wasmer_metering_points_exhausted");
542+
env.set_global(
543+
remaining_points.unwrap().clone(),
544+
points_exhausted.unwrap().clone(),
545+
);
536546

537547
(env, store, instance)
538548
}

packages/vm/src/imports.rs

+10
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,16 @@ mod tests {
663663

664664
env.set_wasmer_instance(Some(instance_ptr));
665665
env.set_gas_left(&mut store, gas_limit);
666+
let remaining_points = wasmer_instance
667+
.exports
668+
.get_global("wasmer_metering_remaining_points");
669+
let points_exhausted = wasmer_instance
670+
.exports
671+
.get_global("wasmer_metering_points_exhausted");
672+
env.set_global(
673+
remaining_points.unwrap().clone(),
674+
points_exhausted.unwrap().clone(),
675+
);
666676
env.set_storage_readonly(false);
667677
}
668678

0 commit comments

Comments
 (0)