git.delta.rocks / unique-network / refs/commits / 1893e990ecfb

difftreelog

feat benchmark destroy_collection

Daniel Shiposha2022-06-09parent: #64cbd21.patch.diff
in: master

1 file changed

modifiedpallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth
7 BoundedVec,7 BoundedVec,
8};8};
99
10use crate::{Config, Pallet, Call};10use up_data_structs::*;
11
12use super::*;
1113
12const SEED: u32 = 1;14const SEED: u32 = 1;
1315
14fn create_data<S: Get<u32>>() -> BoundedVec<u8, S> {16fn create_data<S: Get<u32>>() -> BoundedVec<u8, S> {
15 vec![0; S::get() as usize].try_into().expect("size == S")17 vec![0; S::get() as usize].try_into().expect("size == S")
16}18}
19
20fn create_max_collection<T: Config>(owner: &T::AccountId) -> Result<RmrkCollectionId, DispatchError> {
21 <T as pallet_common::Config>::Currency::deposit_creating(owner, T::CollectionCreationPrice::get());
22
23 let metadata = create_data();
24 let max = None;
25 let symbol = create_data();
26
27 <Pallet<T>>::create_collection(RawOrigin::Signed(owner.clone()).into(), metadata, max, symbol)?;
28
29 Ok(<CollectionIndex<T>>::get() - 1)
30}
1731
18benchmarks! {32benchmarks! {
19 create_collection {33 create_collection {
24 let symbol = create_data();38 let symbol = create_data();
25 }: _(RawOrigin::Signed(caller), metadata, max, symbol)39 }: _(RawOrigin::Signed(caller), metadata, max, symbol)
40
41 destroy_collection {
42 let caller = account("caller", 0, SEED);
43 let collection_id = create_max_collection::<T>(&caller)?;
44 }: _(RawOrigin::Signed(caller), collection_id)
26}45}
2746