diff --git a/core/src/ledger/storage_api/collections/lazy_map.rs b/core/src/ledger/storage_api/collections/lazy_map.rs index 80072f2486..0f60740188 100644 --- a/core/src/ledger/storage_api/collections/lazy_map.rs +++ b/core/src/ledger/storage_api/collections/lazy_map.rs @@ -375,9 +375,11 @@ where let iter = storage_api::iter_prefix(storage, &self.get_data_prefix())?; Ok(iter.map(|key_val_res| { let (key, val) = key_val_res?; + dbg!(&key, &val); let sub_key = LazyCollection::is_valid_sub_key(self, &key)? .ok_or(ReadError::UnexpectedlyEmptyStorageKey) .into_storage_result()?; + dbg!(&sub_key); Ok((sub_key, val)) })) } @@ -523,6 +525,7 @@ where mod test { use super::*; use crate::ledger::storage::testing::TestWlStorage; + use crate::ledger::storage_api::collections::LazyVec; #[test] fn test_lazy_map_basics() -> storage_api::Result<()> { @@ -583,4 +586,30 @@ mod test { Ok(()) } + + #[test] + fn test_nested_map() { + let mut storage = TestWlStorage::default(); + + let key = storage::Key::parse("testing").unwrap(); + let nested_map = + NestedMap::>>::open( + key.clone(), + ); + nested_map + .at(&0_u32) + .at(&"string1".to_string()) + .push(&mut storage, 100_u32) + .unwrap(); + + storage_api::iter_prefix_bytes(&storage, &key) + .unwrap() + .for_each(|a| { + dbg!(a); + }); + + nested_map.iter(&storage).unwrap().for_each(|a| { + dbg!(a); + }); + } } diff --git a/core/src/ledger/storage_api/collections/mod.rs b/core/src/ledger/storage_api/collections/mod.rs index 688b76bd49..c096979dde 100644 --- a/core/src/ledger/storage_api/collections/mod.rs +++ b/core/src/ledger/storage_api/collections/mod.rs @@ -58,7 +58,7 @@ pub trait LazyCollection { type SubKeyWithData: Debug; /// A type of a value in the inner-most collection - type Value: BorshDeserialize; + type Value: BorshDeserialize + Debug; /// Create or use an existing vector with the given storage `key`. fn open(key: storage::Key) -> Self; diff --git a/proof_of_stake/src/lib.rs b/proof_of_stake/src/lib.rs index 23ff3326eb..35738a7556 100644 --- a/proof_of_stake/src/lib.rs +++ b/proof_of_stake/src/lib.rs @@ -2737,6 +2737,7 @@ where validator_slashes_handle(validator).push(storage, slash.clone())?; slashes_handle() + .get_data_handler() .at(&processing_epoch) .at(validator) .push(storage, slash)?;