Skip to content

Commit

Permalink
add make test_utils pub(crate)
Browse files Browse the repository at this point in the history
  • Loading branch information
qalisander committed Mar 25, 2024
1 parent 65fc97f commit 76de402
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[package]
# TODO: Figure out public name before v0.1.0 release.
name = "contracts"
categories = ["no-std", "wasm"]
description = "Contracts for Stylus"
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Unit-testing utilities for Stylus contracts.
use std::sync::{Mutex, MutexGuard};

pub use wavm_shims::*;
pub(crate) use wavm_shims::*;

/// A global static mutex.
///
Expand All @@ -10,15 +10,15 @@ pub use wavm_shims::*;
/// accesses storage in an non-overlapping manner.
///
/// See [`with_storage`].
pub static STORAGE_MUTEX: Mutex<()> = Mutex::new(());
pub(crate) static STORAGE_MUTEX: Mutex<()> = Mutex::new(());

/// Acquires access to storage.
pub fn acquire_storage() -> MutexGuard<'static, ()> {
pub(crate) fn acquire_storage() -> MutexGuard<'static, ()> {
STORAGE_MUTEX.lock().unwrap()
}

/// Decorates a closure by running it with exclusive access to storage.
pub fn with_storage<C: Default>(closure: impl FnOnce(&mut C)) {
pub(crate) fn with_storage<C: Default>(closure: impl FnOnce(&mut C)) {
let _lock = acquire_storage();
let mut contract = C::default();
closure(&mut contract);
Expand Down

0 comments on commit 76de402

Please sign in to comment.