difftreelog
feat benchmark destroy_collection
in: master
1 file changed
pallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth1use sp_std::vec;23use frame_benchmarking::{benchmarks, account};4use frame_system::RawOrigin;5use frame_support::{6 traits::{Currency, Get},7 BoundedVec,8};910use crate::{Config, Pallet, Call};1112const SEED: u32 = 1;1314fn create_data<S: Get<u32>>() -> BoundedVec<u8, S> {15 vec![0; S::get() as usize].try_into().expect("size == S")16}1718benchmarks! {19 create_collection {20 let caller = account("caller", 0, SEED);21 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());22 let metadata = create_data();23 let max = None;24 let symbol = create_data();25 }: _(RawOrigin::Signed(caller), metadata, max, symbol)26}1use sp_std::vec;23use frame_benchmarking::{benchmarks, account};4use frame_system::RawOrigin;5use frame_support::{6 traits::{Currency, Get},7 BoundedVec,8};910use up_data_structs::*;1112use super::*;1314const SEED: u32 = 1;1516fn create_data<S: Get<u32>>() -> BoundedVec<u8, S> {17 vec![0; S::get() as usize].try_into().expect("size == S")18}1920fn create_max_collection<T: Config>(owner: &T::AccountId) -> Result<RmrkCollectionId, DispatchError> {21 <T as pallet_common::Config>::Currency::deposit_creating(owner, T::CollectionCreationPrice::get());2223 let metadata = create_data();24 let max = None;25 let symbol = create_data();2627 <Pallet<T>>::create_collection(RawOrigin::Signed(owner.clone()).into(), metadata, max, symbol)?;2829 Ok(<CollectionIndex<T>>::get() - 1)30}3132benchmarks! {33 create_collection {34 let caller = account("caller", 0, SEED);35 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());36 let metadata = create_data();37 let max = None;38 let symbol = create_data();39 }: _(RawOrigin::Signed(caller), metadata, max, symbol)4041 destroy_collection {42 let caller = account("caller", 0, SEED);43 let collection_id = create_max_collection::<T>(&caller)?;44 }: _(RawOrigin::Signed(caller), collection_id)45}