Skip to content

Commit

Permalink
feat: force set migrator benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
metricaez committed Apr 4, 2024
1 parent 876fe19 commit 63f5aac
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pallets/migration/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![cfg(feature = "runtime-benchmarks")]
use super::*;
use crate::Pallet as Migration;
use frame_benchmarking::v2::*;
use frame_support::{
assert_ok,
dispatch::RawOrigin,
};

const SEED: u32 = 0;

fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}
#[benchmarks()]
pub mod benchmarks {
use super::*;

#[benchmark]
fn force_set_migrator() {
let migrator: T::AccountId = account("migrator", 0, SEED);

#[extrinsic_call]
_(RawOrigin::Root, migrator.clone());

assert_last_event::<T>(Event::MigratorUpdated(migrator).into());
}
}
3 changes: 3 additions & 0 deletions pallets/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ mod mock;
#[cfg(test)]
mod tests;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;

pub use pallet::*;

#[frame_support::pallet]
Expand Down

0 comments on commit 63f5aac

Please sign in to comment.