git.delta.rocks / unique-network / refs/commits / ea3ed4f319a6

difftreelog

source

pallets/structure/src/benchmarking.rs1.9 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use super::*;1819use frame_benchmarking::{benchmarks, account};20use frame_support::traits::{Currency, Get};21use up_data_structs::{22	CreateCollectionData, CollectionMode, CreateItemData, CollectionFlags, CreateNftData,23	budget::Unlimited,24};25use pallet_common::Config as CommonConfig;26use pallet_evm::account::CrossAccountId;2728const SEED: u32 = 1;2930benchmarks! {31	find_parent {32		let caller: T::AccountId = account("caller", 0, SEED);33		let caller_cross = T::CrossAccountId::from_sub(caller.clone());3435		<T as CommonConfig>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());36		T::CollectionDispatch::create(37			caller_cross.clone(),38			caller_cross.clone(),39			CreateCollectionData {40				mode: CollectionMode::NFT,41				..Default::default()42			},43			CollectionFlags::default(),44		)?;45		let dispatch = T::CollectionDispatch::dispatch(CollectionHandle::try_get(CollectionId(1))?);46		let dispatch = dispatch.as_dyn();4748		dispatch.create_item(caller_cross.clone(), caller_cross.clone(), CreateItemData::NFT(CreateNftData::default()), &Unlimited)?;49	}: {50		let parent = <Pallet<T>>::find_parent(CollectionId(1), TokenId(1))?;51		assert!(matches!(parent, Parent::User(_)))52	}53}