mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 01:07:57 +00:00
Implement a CountedStorageMap (#9125)
* initial impl * expose in pallet_prelude * temp test * Apply suggestions from code review Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> * implement with macro help. * test for macro generation * add iterable functions, some test and fixes * fix merge * doc * Update frame/support/src/storage/types/counted_map.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * fix merge * fmt * fix spelling * improve on removal * fix partial storage info * fmt * add license * suggested renames * fix typo * fix test * fmt * fix ui tests * clearer doc * better doc * add metadata test Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
49b6dfd2e5
commit
65e5fa3aa3
@@ -605,6 +605,9 @@ pub mod pallet {
|
||||
#[pallet::getter(fn foo)]
|
||||
pub(super) type Foo<T: Config> = StorageValue<_, T::Balance, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub type CountedMap<T> = CountedStorageMap<_, Blake2_128Concat, u8, u16>;
|
||||
|
||||
// The genesis config type.
|
||||
#[pallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
|
||||
@@ -180,6 +180,15 @@ fn signed_ext_watch_dummy_works() {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn counted_map_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(CountedMap::<Test>::count(), 0);
|
||||
CountedMap::<Test>::insert(3, 3);
|
||||
assert_eq!(CountedMap::<Test>::count(), 1);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weights_work() {
|
||||
// must have a defined weight.
|
||||
|
||||
Reference in New Issue
Block a user