From 166c5d763236950b769701c5a4e870be9ed59902 Mon Sep 17 00:00:00 2001 From: Krayt78 Date: Fri, 22 Nov 2024 16:25:57 +0100 Subject: [PATCH] Migrated Initializer benchmarking to V2 --- .../src/initializer/benchmarking.rs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/polkadot/runtime/parachains/src/initializer/benchmarking.rs b/polkadot/runtime/parachains/src/initializer/benchmarking.rs index 2083c058fd04..850112ed3bf9 100644 --- a/polkadot/runtime/parachains/src/initializer/benchmarking.rs +++ b/polkadot/runtime/parachains/src/initializer/benchmarking.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use super::*; -use frame_benchmarking::benchmarks; +use frame_benchmarking::v2::*; use frame_system::RawOrigin; use polkadot_primitives::ConsensusLog; use sp_runtime::DigestItem; @@ -23,18 +23,25 @@ use sp_runtime::DigestItem; // Random large number for the digest const DIGEST_MAX_LEN: u32 = 65536; -benchmarks! { - force_approve { - let d in 0 .. DIGEST_MAX_LEN; - for _ in 0 .. d { +#[benchmarks] +mod benchmarks { + use super::*; + + #[benchmark] + fn force_approve(d: Linear<0, DIGEST_MAX_LEN>) -> Result<(), BenchmarkError> { + for _ in 0..d { frame_system::Pallet::::deposit_log(ConsensusLog::ForceApprove(d).into()); } - }: _(RawOrigin::Root, d + 1) - verify { + + #[extrinsic_call] + _(RawOrigin::Root, d + 1); + assert_eq!( frame_system::Pallet::::digest().logs.last().unwrap(), &DigestItem::from(ConsensusLog::ForceApprove(d + 1)), ); + + Ok(()) } impl_benchmark_test_suite!(