Skip to content

Commit

Permalink
style: clean up after #49
Browse files Browse the repository at this point in the history
  • Loading branch information
uint committed Jul 10, 2024
1 parent 5e69f94 commit 099aa3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/cw-storey/tests/smoke_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ use cw_storey::{containers::Item, CwStorage};

use storey::containers::{IterableAccessor as _, Map};

// The tests in this module are meant to briefly test the integration of `storey`
// with `cosmwasm_std::Storage` and MessagePack serialization.
//
// They're not meant to comprehensively test the storage abstractions provided by `storey`.
// That's already done in the `storey` crate itself.

#[test]
fn smoke_test() {
// this pattern mimicks how storage is accessed from CosmWasm smart contracts,
// where developers have access to `&dyn cosmwasm_std::Storage` or
// `&mut dyn cosmwasm_std::Storage`, but not the concrete type.
let mut raw_storage = cosmwasm_std::testing::MockStorage::new();
let dyn_storage: &mut dyn cosmwasm_std::Storage = &mut raw_storage;
let mut storage = CwStorage(dyn_storage);
Expand All @@ -30,10 +39,6 @@ fn map() {
map.access(&mut storage).entry_mut("foo").set(&42).unwrap();

assert_eq!(map.access(&storage).entry("foo").get().unwrap(), Some(42));

map.access(&mut storage).entry_mut("foo").remove();

assert_eq!(map.access(&storage).entry("foo").get().unwrap(), None);
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions packages/storey/src/containers/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ where
/// let mut storage = TestStorage::new();
/// let item = Item::<u64, TestEncoding>::new(0);
///
/// item.access(&mut storage).set(&42).unwrap();
/// item.access(&mut storage).remove();
/// assert_eq!(item.access(&storage).get().unwrap(), None);
/// ```
Expand Down

0 comments on commit 099aa3e

Please sign in to comment.