git.delta.rocks / unique-network / refs/commits / 74dc066cb2a1

difftreelog

feat(rmrk) benchmark lock_collection

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

1 file changed

modifiedpallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth
before · pallets/proxy-rmrk-core/src/benchmarking.rs
1use sp_std::vec;23use frame_benchmarking::{benchmarks, account};4use frame_system::RawOrigin;5use frame_support::{6	traits::{Currency, Get},7	BoundedVec,8};9use sp_runtime::traits::AccountIdLookup;1011use up_data_structs::*;1213use super::*;1415const SEED: u32 = 1;1617fn create_data<S: Get<u32>>() -> BoundedVec<u8, S> {18	vec![0; S::get() as usize].try_into().expect("size == S")19}2021fn create_max_collection<T: Config>(owner: &T::AccountId) -> Result<RmrkCollectionId, DispatchError> {22	<T as pallet_common::Config>::Currency::deposit_creating(owner, T::CollectionCreationPrice::get());2324	let metadata = create_data();25	let max = None;26	let symbol = create_data();2728	<Pallet<T>>::create_collection(RawOrigin::Signed(owner.clone()).into(), metadata, max, symbol)?;2930	Ok(<CollectionIndex<T>>::get() - 1)31}3233benchmarks! {34	create_collection {35		let caller = account("caller", 0, SEED);36		<T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());37		let metadata = create_data();38		let max = None;39		let symbol = create_data();40	}: _(RawOrigin::Signed(caller), metadata, max, symbol)4142	destroy_collection {43		let caller = account("caller", 0, SEED);44		let collection_id = create_max_collection::<T>(&caller)?;45	}: _(RawOrigin::Signed(caller), collection_id)4647	change_collection_issuer {48		let caller: T::AccountId = account("caller", 0, SEED);49		let collection_id = create_max_collection::<T>(&caller)?;50		let new_owner: T::AccountId = account("new_owner", 0, SEED);5152		let new_owner_source = T::Lookup::unlookup(new_owner);53	}: _(RawOrigin::Signed(caller), collection_id, new_owner_source)54}
after · pallets/proxy-rmrk-core/src/benchmarking.rs
1use sp_std::vec;23use frame_benchmarking::{benchmarks, account};4use frame_system::RawOrigin;5use frame_support::{6	traits::{Currency, Get},7	BoundedVec,8};9use sp_runtime::traits::AccountIdLookup;1011use up_data_structs::*;1213use super::*;1415const SEED: u32 = 1;1617fn create_data<S: Get<u32>>() -> BoundedVec<u8, S> {18	vec![0; S::get() as usize].try_into().expect("size == S")19}2021fn create_max_collection<T: Config>(owner: &T::AccountId) -> Result<RmrkCollectionId, DispatchError> {22	<T as pallet_common::Config>::Currency::deposit_creating(owner, T::CollectionCreationPrice::get());2324	let metadata = create_data();25	let max = None;26	let symbol = create_data();2728	<Pallet<T>>::create_collection(RawOrigin::Signed(owner.clone()).into(), metadata, max, symbol)?;2930	Ok(<CollectionIndex<T>>::get() - 1)31}3233benchmarks! {34	create_collection {35		let caller = account("caller", 0, SEED);36		<T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());37		let metadata = create_data();38		let max = None;39		let symbol = create_data();40	}: _(RawOrigin::Signed(caller), metadata, max, symbol)4142	destroy_collection {43		let caller = account("caller", 0, SEED);44		let collection_id = create_max_collection::<T>(&caller)?;45	}: _(RawOrigin::Signed(caller), collection_id)4647	change_collection_issuer {48		let caller: T::AccountId = account("caller", 0, SEED);49		let collection_id = create_max_collection::<T>(&caller)?;50		let new_owner: T::AccountId = account("new_owner", 0, SEED);5152		let new_owner_source = T::Lookup::unlookup(new_owner);53	}: _(RawOrigin::Signed(caller), collection_id, new_owner_source)5455	lock_collection {56		let caller: T::AccountId = account("caller", 0, SEED);57		let collection_id = create_max_collection::<T>(&caller)?;58	}: _(RawOrigin::Signed(caller), collection_id)59}