Skip to content
Snippets Groups Projects
Unverified Commit aff3a079 authored by clangenb's avatar clangenb Committed by GitHub
Browse files

migrate pallet-nft-fractionalization to benchmarking v2 syntax (#6301)


Migrates pallet-nft-fractionalization to benchmarking v2 syntax.

Part of:
* #6202

---------

Co-authored-by: default avatarGiuseppe Re <giuseppe.re@parity.io>
Co-authored-by: default avatarGitHub Action <action@github.com>
Co-authored-by: default avatarBastian Köcher <git@kchr.de>
parent 1b0cbe99
No related merge requests found
Pipeline #505163 waiting for manual action with stages
in 32 minutes and 23 seconds
title: migrate pallet-nft-fractionalization to benchmarking v2 syntax
doc:
- audience: Runtime Dev
description: |-
Migrates pallet-nft-fractionalization to benchmarking v2 syntax.
Part of:
* #6202
crates:
- name: pallet-nft-fractionalization
bump: patch
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#![cfg(feature = "runtime-benchmarks")] #![cfg(feature = "runtime-benchmarks")]
use super::*; use super::*;
use frame_benchmarking::{benchmarks, whitelisted_caller}; use frame_benchmarking::v2::*;
use frame_support::{ use frame_support::{
assert_ok, assert_ok,
traits::{ traits::{
...@@ -77,20 +77,37 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) { ...@@ -77,20 +77,37 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
assert_eq!(event, &system_event); assert_eq!(event, &system_event);
} }
benchmarks! { #[benchmarks(
where_clause { where
where T::Nfts:
T::Nfts: Create<T::AccountId, CollectionConfig<BalanceOf<T>, frame_system::pallet_prelude::BlockNumberFor::<T>, T::NftCollectionId>> Create<
+ Mutate<T::AccountId, ItemConfig>, T::AccountId,
} CollectionConfig<BalanceOf<T>,
frame_system::pallet_prelude::BlockNumberFor::<T>,
fractionalize { T::NftCollectionId>
>
+ Mutate<T::AccountId, ItemConfig>,
)]
mod benchmarks {
use super::*;
#[benchmark]
fn fractionalize() {
let asset = T::BenchmarkHelper::asset(0); let asset = T::BenchmarkHelper::asset(0);
let collection = T::BenchmarkHelper::collection(0); let collection = T::BenchmarkHelper::collection(0);
let nft = T::BenchmarkHelper::nft(0); let nft = T::BenchmarkHelper::nft(0);
let (caller, caller_lookup) = mint_nft::<T>(nft); let (caller, caller_lookup) = mint_nft::<T>(nft);
}: _(SystemOrigin::Signed(caller.clone()), collection, nft, asset.clone(), caller_lookup, 1000u32.into())
verify { #[extrinsic_call]
_(
SystemOrigin::Signed(caller.clone()),
collection,
nft,
asset.clone(),
caller_lookup,
1000u32.into(),
);
assert_last_event::<T>( assert_last_event::<T>(
Event::NftFractionalized { Event::NftFractionalized {
nft_collection: collection, nft_collection: collection,
...@@ -98,34 +115,39 @@ benchmarks! { ...@@ -98,34 +115,39 @@ benchmarks! {
fractions: 1000u32.into(), fractions: 1000u32.into(),
asset, asset,
beneficiary: caller, beneficiary: caller,
}.into() }
.into(),
); );
} }
unify { #[benchmark]
fn unify() {
let asset = T::BenchmarkHelper::asset(0); let asset = T::BenchmarkHelper::asset(0);
let collection = T::BenchmarkHelper::collection(0); let collection = T::BenchmarkHelper::collection(0);
let nft = T::BenchmarkHelper::nft(0); let nft = T::BenchmarkHelper::nft(0);
let (caller, caller_lookup) = mint_nft::<T>(nft); let (caller, caller_lookup) = mint_nft::<T>(nft);
NftFractionalization::<T>::fractionalize(
assert_ok!(NftFractionalization::<T>::fractionalize(
SystemOrigin::Signed(caller.clone()).into(), SystemOrigin::Signed(caller.clone()).into(),
collection, collection,
nft, nft,
asset.clone(), asset.clone(),
caller_lookup.clone(), caller_lookup.clone(),
1000u32.into(), 1000u32.into(),
)?; ));
}: _(SystemOrigin::Signed(caller.clone()), collection, nft, asset.clone(), caller_lookup)
verify { #[extrinsic_call]
_(SystemOrigin::Signed(caller.clone()), collection, nft, asset.clone(), caller_lookup);
assert_last_event::<T>( assert_last_event::<T>(
Event::NftUnified { Event::NftUnified { nft_collection: collection, nft, asset, beneficiary: caller }
nft_collection: collection, .into(),
nft,
asset,
beneficiary: caller,
}.into()
); );
} }
impl_benchmark_test_suite!(NftFractionalization, crate::mock::new_test_ext(), crate::mock::Test); impl_benchmark_test_suite!(
NftFractionalization,
crate::mock::new_test_ext(),
crate::mock::Test
);
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment