diff --git a/polkadot/runtime/common/src/coretime/benchmarking.rs b/polkadot/runtime/common/src/coretime/benchmarking.rs index e1f69cdc2694..6ec36fa73e35 100644 --- a/polkadot/runtime/common/src/coretime/benchmarking.rs +++ b/polkadot/runtime/common/src/coretime/benchmarking.rs @@ -19,10 +19,12 @@ #![cfg(feature = "runtime-benchmarks")] use super::{Pallet, *}; +use crate::coretime; use assigner_bulk::MAX_ASSIGNMENTS_PER_SCHEDULE; use frame_benchmarking::v2::*; -use frame_system::RawOrigin; +//use frame_system::RawOrigin; //use xcm::latest::prelude::*; +//use pallet_xcm::Origin; #[benchmarks] mod benchmarks { @@ -31,10 +33,27 @@ mod benchmarks { fn assign_core(s: Linear<0, MAX_ASSIGNMENTS_PER_SCHEDULE>) { // Setup let caller: ::AccountId = whitelisted_caller(); - // TODO: Construct a proper Xcm broker parachain message origin - // let broker_id: u32 = 1004; - // let broker_origin = ::XcmPallet::Origin::Xcm(MultiLocation { parents: 0, - // interior: X1(Parachain(broker_id)) }); + // TODO: This value is copied from BROKER_ID in rococo runtime constants. + // Perhaps provide it in a more future proof way if worth the extra + // dependency. + let broker_id: u32 = 1004; + /*let broker_origin: ::RuntimeOrigin = RuntimeOrigin { + caller: Origin::Xcm(MultiLocation { parents: 0, interior: X1(Parachain(broker_id)) }), + RawOrigin::Signed(caller.into()) + }*/ + let successful_origin: T::RuntimeOrigin = + <::ExternalBrokerOrigin as EnsureOrigin<_>>::try_successful_origin() + .expect("EnsureBrokerOrigin has no successful origin required for the test"); + // Maybe use this kind of stuff to modify the origin after constructing via try_successful_origin + /*fn try_origin(outer: O) -> Result { + outer.try_with_caller(|caller| { + caller.try_into().and_then(|o| match o { + Origin::Xcm(location) if F::contains(&location) => Ok(location), + Origin::Xcm(location) => Err(Origin::Xcm(location).into()), + o => Err(o.into()), + }) + }) + }*/ // Use valid assignment set with maximum number of assignments to maximize work let assignments: Vec<(CoreAssignment, PartsOf57600)> = vec![576u16; s as usize] @@ -45,7 +64,7 @@ mod benchmarks { #[extrinsic_call] _( - RawOrigin::Signed(caller.into()), + successful_origin as T::RuntimeOrigin, CoreIndex(0), BlockNumberFor::::from(5u32), assignments,