Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
trivial changes to trigger dependents breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-paulo-parity committed Dec 17, 2021
1 parent 4f36731 commit 0f3b261
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
36 changes: 18 additions & 18 deletions frame/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ macro_rules! benchmark_backend {
&self,
components: &[($crate::BenchmarkParameter, u32)],
verify: bool
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkErrorFoo>>, $crate::BenchmarkErrorFoo> {
$(
// Prepare instance
let $param = components.iter()
Expand All @@ -796,7 +796,7 @@ macro_rules! benchmark_backend {
$( $param_instancer ; )*
$( $post )*

Ok($crate::Box::new(move || -> Result<(), $crate::BenchmarkError> {
Ok($crate::Box::new(move || -> Result<(), $crate::BenchmarkErrorFoo> {
$eval;
if verify {
$postcode;
Expand Down Expand Up @@ -862,17 +862,17 @@ macro_rules! impl_bench_name_tests {
},
Ok(Err(err)) => {
match err {
$crate::BenchmarkError::Stop(err) => {
$crate::BenchmarkErrorFoo::Stop(err) => {
panic!("{}: {:?}", stringify!($name), err);
},
$crate::BenchmarkError::Override(_) => {
$crate::BenchmarkErrorFoo::Override(_) => {
// This is still considered a success condition.
$crate::log::error!(
"WARNING: benchmark error overrided - {}",
stringify!($name),
);
},
$crate::BenchmarkError::Skip => {
$crate::BenchmarkErrorFoo::Skip => {
// This is considered a success condition.
$crate::log::error!(
"WARNING: benchmark error skipped - {}",
Expand Down Expand Up @@ -907,7 +907,7 @@ macro_rules! impl_bench_name_tests {
// Every variant must implement [`BenchmarkingSetup`].
//
// ```nocompile
//
//
// struct Transfer;
// impl BenchmarkingSetup for Transfer { ... }
//
Expand Down Expand Up @@ -949,7 +949,7 @@ macro_rules! selected_benchmark {
&self,
components: &[($crate::BenchmarkParameter, u32)],
verify: bool
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkErrorFoo>>, $crate::BenchmarkErrorFoo> {
match self {
$(
Self::$bench => <
Expand Down Expand Up @@ -1004,7 +1004,7 @@ macro_rules! impl_benchmark {
whitelist: &[$crate::TrackedStorageKey],
verify: bool,
internal_repeats: u32,
) -> Result<$crate::Vec<$crate::BenchmarkResult>, $crate::BenchmarkError> {
) -> Result<$crate::Vec<$crate::BenchmarkResult>, $crate::BenchmarkErrorFoo> {
// Map the input to the selected benchmark.
let extrinsic = $crate::str::from_utf8(extrinsic)
.map_err(|_| "`extrinsic` is not a valid utf8 string!")?;
Expand Down Expand Up @@ -1125,9 +1125,9 @@ macro_rules! impl_benchmark {
/// by the `impl_benchmark_test_suite` macro. However, it is not an error if a pallet
/// author chooses not to implement benchmarks.
#[allow(unused)]
fn test_bench_by_name(name: &[u8]) -> Result<(), $crate::BenchmarkError> {
fn test_bench_by_name(name: &[u8]) -> Result<(), $crate::BenchmarkErrorFoo> {
let name = $crate::str::from_utf8(name)
.map_err(|_| -> $crate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?;
.map_err(|_| -> $crate::BenchmarkErrorFoo { "`name` is not a valid utf8 string!".into() })?;
match name {
$( stringify!($name) => {
$crate::paste::paste! { Self::[< test_benchmark_ $name >]() }
Expand Down Expand Up @@ -1157,15 +1157,15 @@ macro_rules! impl_benchmark_test {
where T: frame_system::Config, $( $where_clause )*
{
#[allow(unused)]
fn [<test_benchmark_ $name>] () -> Result<(), $crate::BenchmarkError> {
fn [<test_benchmark_ $name>] () -> Result<(), $crate::BenchmarkErrorFoo> {
let selected_benchmark = SelectedBenchmark::$name;
let components = <
SelectedBenchmark as $crate::BenchmarkingSetup<T, _>
>::components(&selected_benchmark);

let execute_benchmark = |
c: $crate::Vec<($crate::BenchmarkParameter, u32)>
| -> Result<(), $crate::BenchmarkError> {
| -> Result<(), $crate::BenchmarkErrorFoo> {
// Set up the benchmark, return execution + verification function.
let closure_to_verify = <
SelectedBenchmark as $crate::BenchmarkingSetup<T, _>
Expand Down Expand Up @@ -1576,7 +1576,7 @@ macro_rules! impl_test_function {
},
Ok(Err(err)) => {
match err {
$crate::BenchmarkError::Stop(err) => {
$crate::BenchmarkErrorFoo::Stop(err) => {
println!(
"{}: {:?}",
$crate::str::from_utf8(benchmark_name)
Expand All @@ -1585,15 +1585,15 @@ macro_rules! impl_test_function {
);
anything_failed = true;
},
$crate::BenchmarkError::Override(_) => {
$crate::BenchmarkErrorFoo::Override(_) => {
// This is still considered a success condition.
$crate::log::error!(
"WARNING: benchmark error overrided - {}",
$crate::str::from_utf8(benchmark_name)
.expect("benchmark name is always a valid string!"),
);
},
$crate::BenchmarkError::Skip => {
$crate::BenchmarkErrorFoo::Skip => {
// This is considered a success condition.
$crate::log::error!(
"WARNING: benchmark error skipped - {}",
Expand Down Expand Up @@ -1725,7 +1725,7 @@ macro_rules! add_benchmark {

let final_results = match benchmark_result {
Ok(results) => Some(results),
Err($crate::BenchmarkError::Override(mut result)) => {
Err($crate::BenchmarkErrorFoo::Override(mut result)) => {
// Insert override warning as the first storage key.
$crate::log::error!(
"WARNING: benchmark error overrided - {}",
Expand All @@ -1737,7 +1737,7 @@ macro_rules! add_benchmark {
);
Some($crate::vec![result])
},
Err($crate::BenchmarkError::Stop(e)) => {
Err($crate::BenchmarkErrorFoo::Stop(e)) => {
$crate::show_benchmark_debug_info(
instance_string,
benchmark,
Expand All @@ -1747,7 +1747,7 @@ macro_rules! add_benchmark {
);
return Err(e.into());
},
Err($crate::BenchmarkError::Skip) => {
Err($crate::BenchmarkErrorFoo::Skip) => {
$crate::log::error!(
"WARNING: benchmark error skipped - {}",
$crate::str::from_utf8(benchmark)
Expand Down
12 changes: 6 additions & 6 deletions frame/benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn new_test_ext() -> sp_io::TestExternalities {

mod benchmarks {
use super::{new_test_ext, pallet_test::Value, Test};
use crate::{account, BenchmarkError, BenchmarkParameter, BenchmarkResult, BenchmarkingSetup};
use crate::{account, BenchmarkErrorFoo, BenchmarkParameter, BenchmarkResult, BenchmarkingSetup};
use frame_support::{assert_err, assert_ok, ensure, traits::Get};
use frame_system::RawOrigin;
use sp_std::prelude::*;
Expand Down Expand Up @@ -211,7 +211,7 @@ mod benchmarks {
let b in 1 .. 1000;
let caller = account::<T::AccountId>("caller", 0, 0);
}: {
Err(BenchmarkError::Override(
Err(BenchmarkErrorFoo::Override(
BenchmarkResult {
extrinsic_time: 1_234_567_890,
reads: 1337,
Expand All @@ -222,7 +222,7 @@ mod benchmarks {
}

skip_benchmark {
let value = T::MaybeItem::get().ok_or(BenchmarkError::Skip)?;
let value = T::MaybeItem::get().ok_or(BenchmarkErrorFoo::Skip)?;
}: {
// This should never be reached.
assert!(value > 100);
Expand Down Expand Up @@ -329,7 +329,7 @@ mod benchmarks {

new_test_ext().execute_with(|| {
let result = closure();
assert!(matches!(result, Err(BenchmarkError::Override(_))));
assert!(matches!(result, Err(BenchmarkErrorFoo::Override(_))));
});
}

Expand All @@ -345,9 +345,9 @@ mod benchmarks {
assert_ok!(Pallet::<Test>::test_benchmark_variable_components());
assert!(matches!(
Pallet::<Test>::test_benchmark_override_benchmark(),
Err(BenchmarkError::Override(_)),
Err(BenchmarkErrorFoo::Override(_)),
));
assert_eq!(Pallet::<Test>::test_benchmark_skip_benchmark(), Err(BenchmarkError::Skip),);
assert_eq!(Pallet::<Test>::test_benchmark_skip_benchmark(), Err(BenchmarkErrorFoo::Skip),);
});
}
}
22 changes: 11 additions & 11 deletions frame/benchmarking/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl BenchmarkResult {

/// Possible errors returned from the benchmarking pipeline.
#[derive(Clone, PartialEq, Debug)]
pub enum BenchmarkError {
pub enum BenchmarkErrorFoo {
/// The benchmarking pipeline should stop and return the inner string.
Stop(&'static str),
/// The benchmarking pipeline is allowed to fail here, and we should use the
Expand All @@ -131,29 +131,29 @@ pub enum BenchmarkError {
Skip,
}

impl From<BenchmarkError> for &'static str {
fn from(e: BenchmarkError) -> Self {
impl From<BenchmarkErrorFoo> for &'static str {
fn from(e: BenchmarkErrorFoo) -> Self {
match e {
BenchmarkError::Stop(s) => s,
BenchmarkError::Override(_) => "benchmark override",
BenchmarkError::Skip => "benchmark skip",
BenchmarkErrorFoo::Stop(s) => s,
BenchmarkErrorFoo::Override(_) => "benchmark override",
BenchmarkErrorFoo::Skip => "benchmark skip",
}
}
}

impl From<&'static str> for BenchmarkError {
impl From<&'static str> for BenchmarkErrorFoo {
fn from(s: &'static str) -> Self {
Self::Stop(s)
}
}

impl From<DispatchErrorWithPostInfo> for BenchmarkError {
impl From<DispatchErrorWithPostInfo> for BenchmarkErrorFoo {
fn from(e: DispatchErrorWithPostInfo) -> Self {
Self::Stop(e.into())
}
}

impl From<DispatchError> for BenchmarkError {
impl From<DispatchError> for BenchmarkErrorFoo {
fn from(e: DispatchError) -> Self {
Self::Stop(e.into())
}
Expand Down Expand Up @@ -302,7 +302,7 @@ pub trait Benchmarking {
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32,
) -> Result<Vec<BenchmarkResult>, BenchmarkError>;
) -> Result<Vec<BenchmarkResult>, BenchmarkErrorFoo>;
}

/// The required setup for creating a benchmark.
Expand All @@ -318,7 +318,7 @@ pub trait BenchmarkingSetup<T, I = ()> {
&self,
components: &[(BenchmarkParameter, u32)],
verify: bool,
) -> Result<Box<dyn FnOnce() -> Result<(), BenchmarkError>>, BenchmarkError>;
) -> Result<Box<dyn FnOnce() -> Result<(), BenchmarkErrorFoo>>, BenchmarkErrorFoo>;
}

/// Grab an account, seeded by a name and index.
Expand Down
4 changes: 2 additions & 2 deletions frame/elections-phragmen/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use super::*;

use frame_benchmarking::{account, benchmarks, whitelist, BenchmarkError, BenchmarkResult};
use frame_benchmarking::{account, benchmarks, whitelist, BenchmarkErrorFoo, BenchmarkResult};
use frame_support::{
dispatch::{DispatchResultWithPostInfo, UnfilteredDispatchable},
traits::OnInitialize,
Expand Down Expand Up @@ -337,7 +337,7 @@ benchmarks! {

// We use the max block weight for this extrinsic for now. See below.
remove_member_without_replacement {}: {
Err(BenchmarkError::Override(
Err(BenchmarkErrorFoo::Override(
BenchmarkResult::from_weight(T::BlockWeights::get().max_block)
))?;
}
Expand Down

0 comments on commit 0f3b261

Please sign in to comment.