Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
LinkedMap doesn't implement StoragePrefixedMap (#4760)
Browse files Browse the repository at this point in the history
* LinkedMap doesn't implement StoragePrefixedMap

* fix test
  • Loading branch information
gui1117 authored Jan 29, 2020
1 parent 5dfd4f2 commit 89e079f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
12 changes: 0 additions & 12 deletions frame/support/procedural/src/storage/storage_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,6 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre
);

quote!(
impl<#impl_trait> #scrate::storage::StoragePrefixedMap<#value_type>
for #storage_struct #optional_storage_where_clause
{
fn module_prefix() -> &'static [u8] {
#instance_or_inherent::PREFIX.as_bytes()
}

fn storage_prefix() -> &'static [u8] {
#storage_name_str.as_bytes()
}
}

impl<#impl_trait> #scrate::#storage_generator_trait for #storage_struct
#optional_storage_where_clause
{
Expand Down
6 changes: 0 additions & 6 deletions frame/support/test/tests/final_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,11 @@ fn final_keys_no_instance() {
k.extend(1u32.using_encoded(blake2_256).to_vec());
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
assert_eq!(unhashed::get::<u32>(&head), Some(1u32));
assert_eq!(&k[..32], &<no_instance::LinkedMap>::final_prefix());

no_instance::LinkedMap2::insert(1, 2);
let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"LinkedMap2")].concat();
k.extend(1u32.using_encoded(twox_128).to_vec());
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
assert_eq!(&k[..32], &<no_instance::LinkedMap2>::final_prefix());

no_instance::DoubleMap::insert(&1, &2, &3);
let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"DoubleMap")].concat();
Expand Down Expand Up @@ -163,13 +161,11 @@ fn final_keys_default_instance() {
k.extend(1u32.using_encoded(blake2_256).to_vec());
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
assert_eq!(unhashed::get::<u32>(&head), Some(1u32));
assert_eq!(&k[..32], &<instance::LinkedMap<instance::DefaultInstance>>::final_prefix());

<instance::LinkedMap2<instance::DefaultInstance>>::insert(1, 2);
let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"LinkedMap2")].concat();
k.extend(1u32.using_encoded(twox_128).to_vec());
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
assert_eq!(&k[..32], &<instance::LinkedMap2<instance::DefaultInstance>>::final_prefix());

<instance::DoubleMap<instance::DefaultInstance>>::insert(&1, &2, &3);
let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"DoubleMap")].concat();
Expand Down Expand Up @@ -214,13 +210,11 @@ fn final_keys_instance_2() {
k.extend(1u32.using_encoded(blake2_256).to_vec());
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
assert_eq!(unhashed::get::<u32>(&head), Some(1u32));
assert_eq!(&k[..32], &<instance::LinkedMap<instance::Instance2>>::final_prefix());

<instance::LinkedMap2<instance::Instance2>>::insert(1, 2);
let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"LinkedMap2")].concat();
k.extend(1u32.using_encoded(twox_128).to_vec());
assert_eq!(unhashed::get::<u32>(&k), Some(2u32));
assert_eq!(&k[..32], &<instance::LinkedMap2<instance::Instance2>>::final_prefix());

<instance::DoubleMap<instance::Instance2>>::insert(&1, &2, &3);
let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"DoubleMap")].concat();
Expand Down

0 comments on commit 89e079f

Please sign in to comment.