Skip to content

Commit 7312d2a

Browse files
committed
update oracle
1 parent e1713bd commit 7312d2a

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

oracle/src/benchmarking.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
pub use crate::*;
22

3-
use frame_benchmarking::v2::{impl_test_function, instance_benchmarks, whitelisted_caller};
4-
3+
use frame_benchmarking::v2::*;
54
use frame_support::assert_ok;
65
use frame_system::{Pallet as System, RawOrigin};
76

7+
/// Helper trait for benchmarking.
8+
pub trait BenchmarkHelper<OracleKey, OracleValue, L: Get<u32>> {
9+
/// Returns a list of `(oracle_key, oracle_value)` pairs to be used for
10+
/// benchmarking.
11+
///
12+
/// NOTE: User should ensure to at least submit two values, otherwise the
13+
/// benchmark linear analysis might fail.
14+
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>;
15+
}
16+
17+
impl<OracleKey, OracleValue, L: Get<u32>> BenchmarkHelper<OracleKey, OracleValue, L> for () {
18+
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L> {
19+
BoundedVec::default()
20+
}
21+
}
22+
823
#[instance_benchmarks]
924
mod benchmarks {
1025
use super::*;

oracle/src/lib.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,18 @@ use sp_std::{prelude::*, vec};
4343
pub use crate::default_combine_data::DefaultCombineData;
4444

4545
#[cfg(feature = "runtime-benchmarks")]
46-
pub mod benchmarking;
46+
mod benchmarking;
4747

4848
mod default_combine_data;
4949
mod mock;
5050
mod tests;
5151
mod weights;
5252

53+
#[cfg(feature = "runtime-benchmarks")]
54+
pub use benchmarking::BenchmarkHelper;
5355
pub use module::*;
5456
pub use weights::WeightInfo;
5557

56-
#[cfg(feature = "runtime-benchmarks")]
57-
/// Helper trait for benchmarking.
58-
pub trait BenchmarkHelper<OracleKey, OracleValue, L: Get<u32>> {
59-
/// Returns a list of `(oracle_key, oracle_value)` pairs to be used for
60-
/// benchmarking.
61-
///
62-
/// NOTE: User should ensure to at least submit two values, otherwise the
63-
/// benchmark linear analysis might fail.
64-
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>;
65-
}
66-
67-
#[cfg(feature = "runtime-benchmarks")]
68-
impl<OracleKey, OracleValue, L: Get<u32>> BenchmarkHelper<OracleKey, OracleValue, L> for () {
69-
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L> {
70-
BoundedVec::default()
71-
}
72-
}
73-
7458
#[frame_support::pallet]
7559
pub mod module {
7660
use super::*;

0 commit comments

Comments
 (0)