From 7e15e2514f9b04c80ce822761ae7825f263ac483 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 25 Apr 2024 10:29:17 +0800 Subject: [PATCH] impl BenchmarkHelper for () --- oracle/src/benchmarking.rs | 3 +-- oracle/src/lib.rs | 7 +++++++ oracle/src/mock.rs | 11 +---------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/oracle/src/benchmarking.rs b/oracle/src/benchmarking.rs index 910bf229c..7c8cc8f25 100644 --- a/oracle/src/benchmarking.rs +++ b/oracle/src/benchmarking.rs @@ -5,14 +5,13 @@ use frame_benchmarking::v2::*; use frame_support::assert_ok; use frame_system::{Pallet as System, RawOrigin}; -use sp_std::vec; #[instance_benchmarks] mod benchmarks { use super::*; #[benchmark] - fn feed_values(x: Linear<1, { T::BenchmarkHelper::get_currency_id_value_pairs().len() as u32 }>) { + fn feed_values(x: Linear<0, { T::BenchmarkHelper::get_currency_id_value_pairs().len() as u32 }>) { // Register the caller let caller: T::AccountId = whitelisted_caller(); T::Members::add(&caller); diff --git a/oracle/src/lib.rs b/oracle/src/lib.rs index 2a0bc3104..ce7ac3074 100644 --- a/oracle/src/lib.rs +++ b/oracle/src/lib.rs @@ -63,6 +63,13 @@ pub trait BenchmarkHelper> { fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>; } +#[cfg(feature = "runtime-benchmarks")] +impl> BenchmarkHelper for () { + fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L> { + BoundedVec::default() + } +} + #[frame_support::pallet] pub mod module { use super::*; diff --git a/oracle/src/mock.rs b/oracle/src/mock.rs index 4907aa0c0..d289439f3 100644 --- a/oracle/src/mock.rs +++ b/oracle/src/mock.rs @@ -63,15 +63,6 @@ impl SortedMembers for Members { } } -#[cfg(feature = "runtime-benchmarks")] -pub struct BenchmarkHelper; -#[cfg(feature = "runtime-benchmarks")] -impl crate::BenchmarkHelper for BenchmarkHelper { - fn get_currency_id_value_pairs() -> BoundedVec<(Key, Value), MaxFeedValues> { - vec![(1, 1), (2, 2), (3, 3)].try_into().unwrap() - } -} - impl Config for Test { type RuntimeEvent = RuntimeEvent; type OnNewData = (); @@ -85,7 +76,7 @@ impl Config for Test { type MaxHasDispatchedSize = ConstU32<100>; type MaxFeedValues = MaxFeedValues; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = BenchmarkHelper; + type BenchmarkHelper = (); } type Block = frame_system::mocking::MockBlock;