Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl oracle::BenchmarkHelper for () #997

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions oracle/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>;
}

#[cfg(feature = "runtime-benchmarks")]
impl<OracleKey, OracleValue, L: Get<u32>> BenchmarkHelper<OracleKey, OracleValue, L> for () {
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L> {
BoundedVec::default()

Check warning on line 69 in oracle/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

oracle/src/lib.rs#L68-L69

Added lines #L68 - L69 were not covered by tests
}
}

#[frame_support::pallet]
pub mod module {
use super::*;
Expand Down
11 changes: 1 addition & 10 deletions oracle/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ impl SortedMembers<AccountId> for Members {
}
}

#[cfg(feature = "runtime-benchmarks")]
pub struct BenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl crate::BenchmarkHelper<Key, Value, MaxFeedValues> 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 = ();
Expand All @@ -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<Test>;
Expand Down
Loading