1234567891011121314151617use frame_benchmarking::v2::{account, benchmarks, BenchmarkError};18use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};19use pallet_common::Config as CommonConfig;20use pallet_evm::account::CrossAccountId;21use sp_std::vec;22use up_data_structs::{23 budget::Unlimited, CollectionMode, CreateCollectionData, CreateItemData, CreateNftData,24};2526use super::*;2728const SEED: u32 = 1;2930#[benchmarks]31mod benchmarks {32 use super::*;3334 #[benchmark]35 fn find_parent() -> Result<(), BenchmarkError> {36 let caller: T::AccountId = account("caller", 0, SEED);37 let caller_cross = T::CrossAccountId::from_sub(caller.clone());3839 let _ = <T as CommonConfig>::Currency::deposit(40 &caller,41 T::CollectionCreationPrice::get(),42 Precision::Exact,43 )44 .unwrap();45 T::CollectionDispatch::create(46 caller_cross.clone(),47 caller_cross.clone(),48 CreateCollectionData {49 mode: CollectionMode::NFT,50 ..Default::default()51 },52 )?;53 let dispatch = T::CollectionDispatch::dispatch(CollectionId(1))?;54 let dispatch = dispatch.as_dyn();5556 dispatch.create_item(57 caller_cross.clone(),58 caller_cross,59 CreateItemData::NFT(CreateNftData::default()),60 &Unlimited,61 )?;6263 #[block]64 {65 let parent = <Pallet<T>>::find_parent(CollectionId(1), TokenId(1))?;66 assert!(matches!(parent, Parent::User(_)));67 }6869 Ok(())70 }71}