mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 02:01:06 +00:00
BREAKING: Rename Call & Event (#11981)
* rename Event to RuntimeEvent * rename Call * rename in runtimes * small fix * rename Event * small fix & rename RuntimeCall back to Call for now * small fixes * more renaming * a bit more renaming * fmt * small fix * commit * prep for renaming associated types * fix * rename associated Event type * rename to RuntimeEvent * commit * merge conflict fixes & fmt * additional renaming * fix. * fix decl_event * rename in tests * remove warnings * remove accidental rename * . * commit * update .stderr * fix in test * update .stderr * TRYBUILD=overwrite * docs * fmt * small change in docs * rename PalletEvent to Event * rename Call to RuntimeCall * renamed at wrong places :P * rename Call * rename * rename associated type * fix * fix & fmt * commit * frame-support-test * passing tests * update docs * rustdoc fix * update .stderr * wrong code in docs * merge fix * fix in error message * update .stderr * docs & error message * . * merge fix * merge fix * fmt * fmt * merge fix * more fixing * fmt * remove unused * fmt * fix Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -77,9 +77,9 @@ fn fill_schedule<T: Config>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn call_and_hash<T: Config>(i: u32) -> (<T as Config>::Call, T::Hash) {
|
||||
fn call_and_hash<T: Config>(i: u32) -> (<T as Config>::RuntimeCall, T::Hash) {
|
||||
// Essentially a no-op call.
|
||||
let call: <T as Config>::Call = frame_system::Call::remark { remark: i.encode() }.into();
|
||||
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: i.encode() }.into();
|
||||
let hash = T::Hashing::hash_of(&call);
|
||||
(call, hash)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,8 @@ pub type PeriodicIndex = u32;
|
||||
/// The location of a scheduled task that can be used to remove it.
|
||||
pub type TaskAddress<BlockNumber> = (BlockNumber, u32);
|
||||
|
||||
pub type CallOrHashOf<T> = MaybeHashed<<T as Config>::Call, <T as frame_system::Config>::Hash>;
|
||||
pub type CallOrHashOf<T> =
|
||||
MaybeHashed<<T as Config>::RuntimeCall, <T as frame_system::Config>::Hash>;
|
||||
|
||||
#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))]
|
||||
#[derive(Clone, RuntimeDebug, Encode, Decode)]
|
||||
@@ -113,7 +114,7 @@ pub struct ScheduledV3<Call, BlockNumber, PalletsOrigin, AccountId> {
|
||||
use crate::ScheduledV3 as ScheduledV2;
|
||||
|
||||
pub type ScheduledV2Of<T> = ScheduledV3<
|
||||
<T as Config>::Call,
|
||||
<T as Config>::RuntimeCall,
|
||||
<T as frame_system::Config>::BlockNumber,
|
||||
<T as Config>::PalletsOrigin,
|
||||
<T as frame_system::Config>::AccountId,
|
||||
@@ -198,7 +199,7 @@ pub mod pallet {
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The aggregated origin which the dispatch will take.
|
||||
type Origin: OriginTrait<PalletsOrigin = Self::PalletsOrigin>
|
||||
@@ -209,7 +210,7 @@ pub mod pallet {
|
||||
type PalletsOrigin: From<system::RawOrigin<Self::AccountId>> + Codec + Clone + Eq + TypeInfo;
|
||||
|
||||
/// The aggregated call type.
|
||||
type Call: Parameter
|
||||
type RuntimeCall: Parameter
|
||||
+ Dispatchable<Origin = <Self as Config>::Origin, PostInfo = PostDispatchInfo>
|
||||
+ GetDispatchInfo
|
||||
+ From<system::Call<Self>>;
|
||||
@@ -543,27 +544,28 @@ impl<T: Config> Pallet<T> {
|
||||
pub fn migrate_v1_to_v3() -> Weight {
|
||||
let mut weight = T::DbWeight::get().reads_writes(1, 1);
|
||||
|
||||
Agenda::<T>::translate::<Vec<Option<ScheduledV1<<T as Config>::Call, T::BlockNumber>>>, _>(
|
||||
|_, agenda| {
|
||||
Some(
|
||||
agenda
|
||||
.into_iter()
|
||||
.map(|schedule| {
|
||||
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1));
|
||||
Agenda::<T>::translate::<
|
||||
Vec<Option<ScheduledV1<<T as Config>::RuntimeCall, T::BlockNumber>>>,
|
||||
_,
|
||||
>(|_, agenda| {
|
||||
Some(
|
||||
agenda
|
||||
.into_iter()
|
||||
.map(|schedule| {
|
||||
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1));
|
||||
|
||||
schedule.map(|schedule| ScheduledV3 {
|
||||
maybe_id: schedule.maybe_id,
|
||||
priority: schedule.priority,
|
||||
call: schedule.call.into(),
|
||||
maybe_periodic: schedule.maybe_periodic,
|
||||
origin: system::RawOrigin::Root.into(),
|
||||
_phantom: Default::default(),
|
||||
})
|
||||
schedule.map(|schedule| ScheduledV3 {
|
||||
maybe_id: schedule.maybe_id,
|
||||
priority: schedule.priority,
|
||||
call: schedule.call.into(),
|
||||
maybe_periodic: schedule.maybe_periodic,
|
||||
origin: system::RawOrigin::Root.into(),
|
||||
_phantom: Default::default(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
},
|
||||
);
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
});
|
||||
|
||||
#[allow(deprecated)]
|
||||
frame_support::storage::migration::remove_storage_prefix(
|
||||
@@ -859,7 +861,7 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> schedule::v2::Anon<T::BlockNumber, <T as Config>::Call, T::PalletsOrigin>
|
||||
impl<T: Config> schedule::v2::Anon<T::BlockNumber, <T as Config>::RuntimeCall, T::PalletsOrigin>
|
||||
for Pallet<T>
|
||||
{
|
||||
type Address = TaskAddress<T::BlockNumber>;
|
||||
@@ -891,7 +893,7 @@ impl<T: Config> schedule::v2::Anon<T::BlockNumber, <T as Config>::Call, T::Palle
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> schedule::v2::Named<T::BlockNumber, <T as Config>::Call, T::PalletsOrigin>
|
||||
impl<T: Config> schedule::v2::Named<T::BlockNumber, <T as Config>::RuntimeCall, T::PalletsOrigin>
|
||||
for Pallet<T>
|
||||
{
|
||||
type Address = TaskAddress<T::BlockNumber>;
|
||||
|
||||
@@ -58,7 +58,7 @@ pub mod logger {
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
@@ -110,9 +110,9 @@ frame_support::construct_runtime!(
|
||||
|
||||
// Scheduler must dispatch with root and no filter, this tests base filter is indeed not used.
|
||||
pub struct BaseFilter;
|
||||
impl Contains<Call> for BaseFilter {
|
||||
fn contains(call: &Call) -> bool {
|
||||
!matches!(call, Call::Logger(LoggerCall::log { .. }))
|
||||
impl Contains<RuntimeCall> for BaseFilter {
|
||||
fn contains(call: &RuntimeCall) -> bool {
|
||||
!matches!(call, RuntimeCall::Logger(LoggerCall::log { .. }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ impl system::Config for Test {
|
||||
type BlockLength = ();
|
||||
type DbWeight = RocksDbWeight;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
@@ -134,7 +134,7 @@ impl system::Config for Test {
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
@@ -147,7 +147,7 @@ impl system::Config for Test {
|
||||
type MaxConsumers = ConstU32<16>;
|
||||
}
|
||||
impl logger::Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
parameter_types! {
|
||||
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
|
||||
@@ -158,7 +158,7 @@ ord_parameter_types! {
|
||||
}
|
||||
|
||||
impl pallet_preimage::Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Currency = ();
|
||||
type ManagerOrigin = EnsureRoot<u64>;
|
||||
@@ -168,10 +168,10 @@ impl pallet_preimage::Config for Test {
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type PalletsOrigin = OriginCaller;
|
||||
type Call = Call;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type MaximumWeight = MaximumSchedulerWeight;
|
||||
type ScheduleOrigin = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
|
||||
type MaxScheduledPerBlock = ConstU32<10>;
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
//! # Scheduler tests.
|
||||
|
||||
use super::*;
|
||||
use crate::mock::{logger, new_test_ext, root, run_to_block, Call, LoggerCall, Scheduler, Test, *};
|
||||
use crate::mock::{
|
||||
logger, new_test_ext, root, run_to_block, LoggerCall, RuntimeCall, Scheduler, Test, *,
|
||||
};
|
||||
use frame_support::{
|
||||
assert_err, assert_noop, assert_ok,
|
||||
traits::{Contains, GetStorageVersion, OnInitialize, PreimageProvider},
|
||||
@@ -30,7 +32,8 @@ use substrate_test_utils::assert_eq_uvec;
|
||||
#[test]
|
||||
fn basic_scheduling_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_ok!(Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into()));
|
||||
run_to_block(3);
|
||||
@@ -45,7 +48,8 @@ fn basic_scheduling_works() {
|
||||
#[test]
|
||||
fn scheduling_with_preimages_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let hash = <Test as frame_system::Config>::Hashing::hash_of(&call);
|
||||
let hashed = MaybeHashed::Hash(hash);
|
||||
assert_ok!(Preimage::note_preimage(Origin::signed(0), call.encode()));
|
||||
@@ -65,7 +69,8 @@ fn scheduling_with_preimages_works() {
|
||||
#[test]
|
||||
fn scheduling_with_preimage_postpones_correctly() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let hash = <Test as frame_system::Config>::Hashing::hash_of(&call);
|
||||
let hashed = MaybeHashed::Hash(hash);
|
||||
|
||||
@@ -98,7 +103,8 @@ fn scheduling_with_preimage_postpones_correctly() {
|
||||
fn schedule_after_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(2);
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
// This will schedule the call 3 blocks after the next block... so block 3 + 3 = 6
|
||||
assert_ok!(Scheduler::do_schedule(DispatchTime::After(3), None, 127, root(), call.into()));
|
||||
@@ -115,7 +121,8 @@ fn schedule_after_works() {
|
||||
fn schedule_after_zero_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(2);
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_ok!(Scheduler::do_schedule(DispatchTime::After(0), None, 127, root(), call.into()));
|
||||
// Will trigger on the next block.
|
||||
@@ -135,7 +142,8 @@ fn periodic_scheduling_works() {
|
||||
Some((3, 3)),
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(logger::Call::log { i: 42, weight: Weight::from_ref_time(1000) }).into()
|
||||
RuntimeCall::Logger(logger::Call::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into()
|
||||
));
|
||||
run_to_block(3);
|
||||
assert!(logger::log().is_empty());
|
||||
@@ -157,7 +165,8 @@ fn periodic_scheduling_works() {
|
||||
#[test]
|
||||
fn reschedule_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_eq!(
|
||||
Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into()).unwrap(),
|
||||
@@ -188,7 +197,8 @@ fn reschedule_works() {
|
||||
#[test]
|
||||
fn reschedule_named_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_eq!(
|
||||
Scheduler::do_schedule_named(
|
||||
@@ -230,7 +240,8 @@ fn reschedule_named_works() {
|
||||
#[test]
|
||||
fn reschedule_named_perodic_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
let call =
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_eq!(
|
||||
Scheduler::do_schedule_named(
|
||||
@@ -292,7 +303,8 @@ fn cancel_named_scheduling_works_with_normal_cancel() {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
let i = Scheduler::do_schedule(
|
||||
@@ -300,7 +312,8 @@ fn cancel_named_scheduling_works_with_normal_cancel() {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
run_to_block(3);
|
||||
@@ -322,7 +335,8 @@ fn cancel_named_periodic_scheduling_works() {
|
||||
Some((3, 3)),
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
// same id results in error.
|
||||
@@ -332,7 +346,8 @@ fn cancel_named_periodic_scheduling_works() {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
)
|
||||
.is_err());
|
||||
// different id is ok.
|
||||
@@ -342,7 +357,8 @@ fn cancel_named_periodic_scheduling_works() {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
run_to_block(3);
|
||||
@@ -364,16 +380,22 @@ fn scheduler_respects_weight_limits() {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 42,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
// 69 and 42 do not fit together
|
||||
run_to_block(4);
|
||||
@@ -391,16 +413,22 @@ fn scheduler_respects_hard_deadlines_more() {
|
||||
None,
|
||||
0,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 42,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
0,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
// With base weights, 69 and 42 should not fit together, but do because of hard
|
||||
// deadlines
|
||||
@@ -417,16 +445,22 @@ fn scheduler_respects_priority_ordering() {
|
||||
None,
|
||||
1,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 42,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
0,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
run_to_block(4);
|
||||
assert_eq!(logger::log(), vec![(root(), 69u32), (root(), 42u32)]);
|
||||
@@ -444,21 +478,23 @@ fn scheduler_respects_priority_ordering_with_soft_deadlines() {
|
||||
None,
|
||||
255,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: max_weight / 2 - item_weight }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: max_weight / 2 - item_weight })
|
||||
.into(),
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: max_weight / 2 - item_weight }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: max_weight / 2 - item_weight })
|
||||
.into(),
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
126,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log {
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 2600,
|
||||
weight: max_weight / 2 - item_weight + Weight::from_ref_time(1)
|
||||
})
|
||||
@@ -487,8 +523,11 @@ fn on_initialize_weight_is_correct() {
|
||||
None,
|
||||
255,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 3, weight: call_weight + Weight::from_ref_time(1) })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 3,
|
||||
weight: call_weight + Weight::from_ref_time(1)
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
// Anon Periodic
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
@@ -496,8 +535,11 @@ fn on_initialize_weight_is_correct() {
|
||||
Some((1000, 3)),
|
||||
128,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: call_weight + Weight::from_ref_time(2) })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 42,
|
||||
weight: call_weight + Weight::from_ref_time(2)
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
// Anon
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
@@ -505,8 +547,11 @@ fn on_initialize_weight_is_correct() {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: call_weight + Weight::from_ref_time(3) })
|
||||
.into(),
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: call_weight + Weight::from_ref_time(3)
|
||||
})
|
||||
.into(),
|
||||
));
|
||||
// Named Periodic
|
||||
assert_ok!(Scheduler::do_schedule_named(
|
||||
@@ -515,7 +560,7 @@ fn on_initialize_weight_is_correct() {
|
||||
Some((1000, 3)),
|
||||
126,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log {
|
||||
RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 2600,
|
||||
weight: call_weight + Weight::from_ref_time(4)
|
||||
})
|
||||
@@ -567,10 +612,12 @@ fn on_initialize_weight_is_correct() {
|
||||
fn root_calls_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
let call2 = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
assert_ok!(Scheduler::schedule_named(Origin::root(), 1u32.encode(), 4, None, 127, call,));
|
||||
assert_ok!(Scheduler::schedule(Origin::root(), 4, None, 127, call2));
|
||||
@@ -592,15 +639,17 @@ fn fails_to_schedule_task_in_the_past() {
|
||||
run_to_block(3);
|
||||
|
||||
let call1 = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
let call2 = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
let call3 = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
|
||||
assert_err!(
|
||||
Scheduler::schedule_named(Origin::root(), 1u32.encode(), 2, None, 127, call1),
|
||||
Error::<Test>::TargetBlockNumberInPast,
|
||||
@@ -622,10 +671,12 @@ fn fails_to_schedule_task_in_the_past() {
|
||||
fn should_use_orign() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
let call2 = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
assert_ok!(Scheduler::schedule_named(
|
||||
system::RawOrigin::Signed(1).into(),
|
||||
@@ -652,10 +703,12 @@ fn should_use_orign() {
|
||||
fn should_check_orign() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
let call2 = Box::new(
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(),
|
||||
RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) })
|
||||
.into(),
|
||||
);
|
||||
assert_noop!(
|
||||
Scheduler::schedule_named(
|
||||
@@ -679,14 +732,14 @@ fn should_check_orign() {
|
||||
fn should_check_orign_for_cancel() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(
|
||||
Call::Logger(LoggerCall::log_without_filter {
|
||||
RuntimeCall::Logger(LoggerCall::log_without_filter {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000),
|
||||
})
|
||||
.into(),
|
||||
);
|
||||
let call2 = Box::new(
|
||||
Call::Logger(LoggerCall::log_without_filter {
|
||||
RuntimeCall::Logger(LoggerCall::log_without_filter {
|
||||
i: 42,
|
||||
weight: Weight::from_ref_time(1000),
|
||||
})
|
||||
@@ -735,7 +788,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV1 {
|
||||
maybe_id: None,
|
||||
priority: i as u8 + 10,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100),
|
||||
}),
|
||||
@@ -745,7 +798,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV1 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000),
|
||||
}),
|
||||
@@ -766,7 +819,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: None,
|
||||
priority: 10,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100)
|
||||
})
|
||||
@@ -779,7 +832,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000)
|
||||
})
|
||||
@@ -796,7 +849,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: None,
|
||||
priority: 11,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100)
|
||||
})
|
||||
@@ -809,7 +862,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000)
|
||||
})
|
||||
@@ -826,7 +879,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: None,
|
||||
priority: 12,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100)
|
||||
})
|
||||
@@ -839,7 +892,7 @@ fn migration_to_v3_works() {
|
||||
Some(ScheduledV3Of::<Test> {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000)
|
||||
})
|
||||
@@ -866,7 +919,7 @@ fn test_migrate_origin() {
|
||||
Some(Scheduled {
|
||||
maybe_id: None,
|
||||
priority: i as u8 + 10,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100),
|
||||
})
|
||||
@@ -880,7 +933,7 @@ fn test_migrate_origin() {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
origin: 2u32,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000),
|
||||
})
|
||||
@@ -913,7 +966,7 @@ fn test_migrate_origin() {
|
||||
Some(ScheduledV2::<CallOrHashOf<Test>, u64, OriginCaller, u64> {
|
||||
maybe_id: None,
|
||||
priority: 10,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100)
|
||||
})
|
||||
@@ -926,7 +979,7 @@ fn test_migrate_origin() {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000)
|
||||
})
|
||||
@@ -943,7 +996,7 @@ fn test_migrate_origin() {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: None,
|
||||
priority: 11,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100)
|
||||
})
|
||||
@@ -956,7 +1009,7 @@ fn test_migrate_origin() {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000)
|
||||
})
|
||||
@@ -973,7 +1026,7 @@ fn test_migrate_origin() {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: None,
|
||||
priority: 12,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 96,
|
||||
weight: Weight::from_ref_time(100)
|
||||
})
|
||||
@@ -986,7 +1039,7 @@ fn test_migrate_origin() {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log {
|
||||
call: RuntimeCall::Logger(LoggerCall::log {
|
||||
i: 69,
|
||||
weight: Weight::from_ref_time(1000)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user