Support NMap in generate_storage_alias (#9147)

* Support NMap in generate_storage_alias

* Verify that 2-key NMap is identical to DoubleMap

* Also compare key hashes and make sure they're identical

* Fix and add tests for 1-tuple NMap generated by generate_storage_alias
This commit is contained in:
Keith Yeung
2021-06-28 02:17:28 -07:00
committed by GitHub
parent 0cccd282a1
commit fb1bd5735c
4 changed files with 69 additions and 10 deletions
@@ -433,6 +433,26 @@ mod test_iterators {
prefix
}
#[test]
fn n_map_double_map_identical_key() {
sp_io::TestExternalities::default().execute_with(|| {
NMap::insert((1, 2), 50);
let key_hash = NMap::hashed_key_for((1, 2));
{
crate::generate_storage_alias!(Test, NMap => DoubleMap<
(u16, crate::Blake2_128Concat),
(u32, crate::Twox64Concat),
u64
>);
let value = NMap::get(1, 2).unwrap();
assert_eq!(value, 50);
assert_eq!(NMap::hashed_key_for(1, 2), key_hash);
}
});
}
#[test]
fn n_map_reversible_reversible_iteration() {
sp_io::TestExternalities::default().execute_with(|| {