mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Enrich metadata with type information (#8615)
* Cargo.lock after merge * Restore scale-info feature * Fully qualify TypeInfo derive * Skip PendingSwap T * Add missing skip_type_params attr * metadata docs features * Reduce pallet event attribute to struct * Cargo.lock * Update frame/balances/src/tests_composite.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Line widths check * Cargo.lock * Add scale-info/std * Update frame/system/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Use `skip_type_params` to remove `TypeInfo` requirements on checks * Revert "Remove unused Call metadata stuff" This reverts commit 41311f85 * Skip BalanceSwapAction type parameter * Remove unused event metadata macro * Update frame-metadata * Update primitives/npos-elections/compact/src/codec.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Manual TypeInfo for Header * Remove TypeInfo requirement for consts in BoundedVec etc. * Another TypeInfo bound removed * review: fix indentation * TypeInfo impls for Identity types * Add some todos to add custom TypeInfo impls * Update frame/support/procedural/src/pallet/expand/pallet_struct.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Add some todos to add custom TypeInfo impls * Add a test for manual Data TypeInfo impl * Add custom TypeInfo impl for Vote * Era custom TypeInfo crimes * Revert finality-grandpa version to 0.14.z * review: renamed module to pallet_constants_metadata * New line at end of file * Add missing scale-info/std * Update frame/support/src/storage/types/mod.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Remove StorageEntryType::Map unused flag * Add missing scale-info dependency after merge * SignedExtension::AdditionalSigned metadata * Update frame-metadata, use abbreviated docs and args fields * Update frame/example/Cargo.toml Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Add scale_info/std and remove unused scale-info dependency * Remove scale-info dependency * Remove treasury pallet::metadata * Remove redundant Event test * Add back scale-info as dev dependency * fix error metadata when no error defined in decl_module * Add Module3 to tests * Fix metadata test * Add docs feature to frame-support test * WIP fixing pallet metadata test * Remove redundant FunctionMetadata, FunctionArgumentMetadata as per https://github.com/paritytech/frame-metadata/pull/20 * Use main branch of frame-metadata * Use patch of scale-info for latest changes * Use latest patched scale-info * Manual TypeInfo for DigestItem * Manual TypeInfo for DigestItem * Update scale-info * Skip __Ignore variants for Error, depends on https://github.com/paritytech/scale-info/pull/117 * Named fields for FRAME v2 pallet Call variants * Named fields for FRAME v1 pallet Call variants * Add missing scale-info dependency * WIP expand benchmark call variant * fix benchmark with new function create a new function for each variant of a pallet call. This function is called by benchmarking macro in order not to break call creation with unnamed argument * fix tests * more fix * Fix staking tests * Fix offchain workers calls * Cherry pick rustfmt.toml from master * cargo +nightly-2021-06-22 fmt --all * Update to new call variant structs * More call variant struct updates * Remove unused import * More call variant structs * More call variant structs * Even more call variant structs * Mooar variant structs * Evermore variant structs * Call variant structs ad infinitum * Fmt * More call variants * Last call variant * Call variants all done? * Fix SS58Prefix type * Potential workaround for BitFlags<IdentityFields> TypeInfo * Enable docs capturing for Call, Event, and Error types * Fix IdentityFields TypeInfo * Remove metadata-docs feature * Add capture_docs = true for legacy Call, Event and Error types * Fmt * Fix metadata test type * Update benchmarks with call struct variants * Fmt * More test fixes * Fmt * Fix benches * Use latest capture_docs attr * Latest scale_info * Fmt * review: change &Vec to &[] * Remove pallet metadata attr * review: remove commented out test code * review: skip_type_params trailing comma suggestion * Update to scale-info 0.10.0 * Update construct_runtime ui tests, different because of metadata TypeInfo impls * Add some TypeInfo derives for UI tests * Update storage ensure span ui stderrs * Update call argument bound ui tests Possibly changed because change from tuple to struct variants? * Add scale-info dev dependency * Update to latest finality-grandpa release * review: missing newline * review: missing scale-info/std * review: remove duplicate scale-info/std * review: remove fully qualified TypeInfo * review: add missing scale-info/std * review: remove unnecessary imports. * Fmt * Use crates.io RC version of frame-metadata * Remove scale-info/std because it is a dev dependency * Add missing scale_info dev-dependency for test * Delete empty metadata folder * Fix sp_std import * review: improve manual UncheckedExtrinsic TypeInfo impl * review: use full scale-info for dev-dependency * Remove DefaultByteGetter impl * review: derive TypeInfo for generic header * Fmt * Update primitives/runtime/src/generic/unchecked_extrinsic.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Update primitives/runtime/src/generic/unchecked_extrinsic.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Update bin/node/executor/Cargo.toml Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/identity/src/types.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/support/src/dispatch.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove redundant derive * Simplify scale-info dependency * Strip underscore prefix from call variant struct names * Another underscore field * More underscore fields * Another underscore field * Update to frame-metadata 14.0.0-rc.2 with combined StorageEntryType::Map * Fmt * Revert weights formatting * Fix up some tests * Fix up some tests for StorageEntryTypeMetadata * scale-info dev dependency * Fix test error * Add missing TypeInfo derives * Add back missing scale-info dependency * Add back missing scale-info dependency * Fix npos compact impls * Cargo.lock * Fmt * Fix errors * Fmt * Fix renamed raw_solution field * Fix error * Fmt * Fix some benchmarks * Fmt * Stray R * Fix * Add missing TypeInfos * ui test fix * Fix line widths * Revert "ui test fix" This reverts commit 2d15ec058a216e3f92d713f1174603a2bb1eac65. * Upgrade to scale-info 0.11.0 * Revert "Upgrade to scale-info 0.11.0" This reverts commit 047bb179085a0059c36cd20ab405f55cf0867e28. * Add Runtime type * Update to scale-info 0.12 * Update to scale-info 1.0 * Update frame-metadata to version 14.0.0 * Patch finality-grandpa until release available * Fix metadata tests * Fix metadata tests * Fmt * Remove patched finality-grandpa * Fix tests, use scale_info imports * Fix pallet tests * Add BlockNumber TypeInfo bound * ui test fix * Cargo.lock * Remove pallet metadata * Cargo.lock * Add missing scale-info dependency * Remove pallet event metadata * Fix error * Fix collective errors * Semicolol * Fmt * Remove another metadata attribute * Add new variant to custom digest TypeInfo * Fmt * Cargo.lock from master * Remove comma lol * Fix example call error * Fix example call error properly Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -64,6 +64,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
pub use pallet::*;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{BadOrigin, One, Saturating, Zero},
|
||||
RuntimeDebug,
|
||||
@@ -87,7 +88,7 @@ struct ScheduledV1<Call, BlockNumber> {
|
||||
|
||||
/// Information regarding an item to be executed in the future.
|
||||
#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))]
|
||||
#[derive(Clone, RuntimeDebug, Encode, Decode)]
|
||||
#[derive(Clone, RuntimeDebug, Encode, Decode, TypeInfo)]
|
||||
pub struct ScheduledV2<Call, BlockNumber, PalletsOrigin, AccountId> {
|
||||
/// The unique identity for this task, if there is one.
|
||||
maybe_id: Option<Vec<u8>>,
|
||||
@@ -109,7 +110,7 @@ pub type Scheduled<Call, BlockNumber, PalletsOrigin, AccountId> =
|
||||
// A value placed in storage that represents the current version of the Scheduler storage.
|
||||
// This value is used by the `on_runtime_upgrade` logic to determine whether we run
|
||||
// storage migration logic.
|
||||
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug)]
|
||||
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||
enum Releases {
|
||||
V1,
|
||||
V2,
|
||||
@@ -143,7 +144,7 @@ pub mod pallet {
|
||||
+ IsType<<Self as system::Config>::Origin>;
|
||||
|
||||
/// The caller origin, overarching type of all pallets origins.
|
||||
type PalletsOrigin: From<system::RawOrigin<Self::AccountId>> + Codec + Clone + Eq;
|
||||
type PalletsOrigin: From<system::RawOrigin<Self::AccountId>> + Codec + Clone + Eq + TypeInfo;
|
||||
|
||||
/// The aggregated call type.
|
||||
type Call: Parameter
|
||||
@@ -192,7 +193,6 @@ pub mod pallet {
|
||||
/// Events type.
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
#[pallet::metadata(T::BlockNumber = "BlockNumber", TaskAddress<T::BlockNumber> = "TaskAddress<BlockNumber>")]
|
||||
pub enum Event<T: Config> {
|
||||
/// Scheduled some task. \[when, index\]
|
||||
Scheduled(T::BlockNumber, u32),
|
||||
@@ -926,7 +926,7 @@ mod tests {
|
||||
pub struct BaseFilter;
|
||||
impl Contains<Call> for BaseFilter {
|
||||
fn contains(call: &Call) -> bool {
|
||||
!matches!(call, Call::Logger(LoggerCall::log(_, _)))
|
||||
!matches!(call, Call::Logger(LoggerCall::log { .. }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1004,7 +1004,7 @@ mod tests {
|
||||
#[test]
|
||||
fn basic_scheduling_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log(42, 1000));
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_ok!(Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call));
|
||||
run_to_block(3);
|
||||
@@ -1020,7 +1020,7 @@ mod tests {
|
||||
fn schedule_after_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(2);
|
||||
let call = Call::Logger(LoggerCall::log(42, 1000));
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: 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));
|
||||
@@ -1037,7 +1037,7 @@ mod tests {
|
||||
fn schedule_after_zero_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(2);
|
||||
let call = Call::Logger(LoggerCall::log(42, 1000));
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_ok!(Scheduler::do_schedule(DispatchTime::After(0), None, 127, root(), call));
|
||||
// Will trigger on the next block.
|
||||
@@ -1057,7 +1057,7 @@ mod tests {
|
||||
Some((3, 3)),
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(logger::Call::log(42, 1000))
|
||||
Call::Logger(logger::Call::log { i: 42, weight: 1000 })
|
||||
));
|
||||
run_to_block(3);
|
||||
assert!(logger::log().is_empty());
|
||||
@@ -1079,7 +1079,7 @@ mod tests {
|
||||
#[test]
|
||||
fn reschedule_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log(42, 1000));
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_eq!(
|
||||
Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call).unwrap(),
|
||||
@@ -1110,7 +1110,7 @@ mod tests {
|
||||
#[test]
|
||||
fn reschedule_named_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log(42, 1000));
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_eq!(
|
||||
Scheduler::do_schedule_named(
|
||||
@@ -1152,7 +1152,7 @@ mod tests {
|
||||
#[test]
|
||||
fn reschedule_named_perodic_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Call::Logger(LoggerCall::log(42, 1000));
|
||||
let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 });
|
||||
assert!(!<Test as frame_system::Config>::BaseCallFilter::contains(&call));
|
||||
assert_eq!(
|
||||
Scheduler::do_schedule_named(
|
||||
@@ -1214,7 +1214,7 @@ mod tests {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, 1000)),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
)
|
||||
.unwrap();
|
||||
let i = Scheduler::do_schedule(
|
||||
@@ -1222,7 +1222,7 @@ mod tests {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(42, 1000)),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: 1000 }),
|
||||
)
|
||||
.unwrap();
|
||||
run_to_block(3);
|
||||
@@ -1244,7 +1244,7 @@ mod tests {
|
||||
Some((3, 3)),
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(42, 1000)),
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: 1000 }),
|
||||
)
|
||||
.unwrap();
|
||||
// same id results in error.
|
||||
@@ -1254,7 +1254,7 @@ mod tests {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, 1000))
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: 1000 })
|
||||
)
|
||||
.is_err());
|
||||
// different id is ok.
|
||||
@@ -1264,7 +1264,7 @@ mod tests {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, 1000)),
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
)
|
||||
.unwrap();
|
||||
run_to_block(3);
|
||||
@@ -1286,14 +1286,14 @@ mod tests {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(42, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
// 69 and 42 do not fit together
|
||||
run_to_block(4);
|
||||
@@ -1311,14 +1311,14 @@ mod tests {
|
||||
None,
|
||||
0,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(42, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
0,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
// With base weights, 69 and 42 should not fit together, but do because of hard
|
||||
// deadlines
|
||||
@@ -1335,14 +1335,14 @@ mod tests {
|
||||
None,
|
||||
1,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(42, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
0,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
run_to_block(4);
|
||||
assert_eq!(logger::log(), vec![(root(), 69u32), (root(), 42u32)]);
|
||||
@@ -1357,21 +1357,24 @@ mod tests {
|
||||
None,
|
||||
255,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(42, MaximumSchedulerWeight::get() / 3))
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 3 })
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
DispatchTime::At(4),
|
||||
None,
|
||||
126,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(2600, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log {
|
||||
i: 2600,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
));
|
||||
|
||||
// 2600 does not fit with 69 or 42, but has higher priority, so will go through
|
||||
@@ -1400,7 +1403,7 @@ mod tests {
|
||||
None,
|
||||
255,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(3, MaximumSchedulerWeight::get() / 3))
|
||||
Call::Logger(LoggerCall::log { i: 3, weight: MaximumSchedulerWeight::get() / 3 })
|
||||
));
|
||||
// Anon Periodic
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
@@ -1408,7 +1411,7 @@ mod tests {
|
||||
Some((1000, 3)),
|
||||
128,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(42, MaximumSchedulerWeight::get() / 3))
|
||||
Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 3 })
|
||||
));
|
||||
// Anon
|
||||
assert_ok!(Scheduler::do_schedule(
|
||||
@@ -1416,7 +1419,7 @@ mod tests {
|
||||
None,
|
||||
127,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(69, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 })
|
||||
));
|
||||
// Named Periodic
|
||||
assert_ok!(Scheduler::do_schedule_named(
|
||||
@@ -1425,7 +1428,10 @@ mod tests {
|
||||
Some((1000, 3)),
|
||||
126,
|
||||
root(),
|
||||
Call::Logger(LoggerCall::log(2600, MaximumSchedulerWeight::get() / 2))
|
||||
Call::Logger(LoggerCall::log {
|
||||
i: 2600,
|
||||
weight: MaximumSchedulerWeight::get() / 2
|
||||
})
|
||||
));
|
||||
|
||||
// Will include the named periodic only
|
||||
@@ -1469,8 +1475,8 @@ mod tests {
|
||||
#[test]
|
||||
fn root_calls_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(Call::Logger(LoggerCall::log(69, 1000)));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log(42, 1000)));
|
||||
let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }));
|
||||
assert_ok!(Scheduler::schedule_named(
|
||||
Origin::root(),
|
||||
1u32.encode(),
|
||||
@@ -1497,8 +1503,8 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
run_to_block(3);
|
||||
|
||||
let call = Box::new(Call::Logger(LoggerCall::log(69, 1000)));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log(42, 1000)));
|
||||
let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }));
|
||||
|
||||
assert_err!(
|
||||
Scheduler::schedule_named(Origin::root(), 1u32.encode(), 2, None, 127, call),
|
||||
@@ -1520,8 +1526,8 @@ mod tests {
|
||||
#[test]
|
||||
fn should_use_orign() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(Call::Logger(LoggerCall::log(69, 1000)));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log(42, 1000)));
|
||||
let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }));
|
||||
assert_ok!(Scheduler::schedule_named(
|
||||
system::RawOrigin::Signed(1).into(),
|
||||
1u32.encode(),
|
||||
@@ -1552,8 +1558,8 @@ mod tests {
|
||||
#[test]
|
||||
fn should_check_orign() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(Call::Logger(LoggerCall::log(69, 1000)));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log(42, 1000)));
|
||||
let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }));
|
||||
assert_noop!(
|
||||
Scheduler::schedule_named(
|
||||
system::RawOrigin::Signed(2).into(),
|
||||
@@ -1575,8 +1581,10 @@ mod tests {
|
||||
#[test]
|
||||
fn should_check_orign_for_cancel() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(Call::Logger(LoggerCall::log_without_filter(69, 1000)));
|
||||
let call2 = Box::new(Call::Logger(LoggerCall::log_without_filter(42, 1000)));
|
||||
let call =
|
||||
Box::new(Call::Logger(LoggerCall::log_without_filter { i: 69, weight: 1000 }));
|
||||
let call2 =
|
||||
Box::new(Call::Logger(LoggerCall::log_without_filter { i: 42, weight: 1000 }));
|
||||
assert_ok!(Scheduler::schedule_named(
|
||||
system::RawOrigin::Signed(1).into(),
|
||||
1u32.encode(),
|
||||
@@ -1626,14 +1634,14 @@ mod tests {
|
||||
Some(ScheduledV1 {
|
||||
maybe_id: None,
|
||||
priority: i as u8 + 10,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
maybe_periodic: None,
|
||||
}),
|
||||
None,
|
||||
Some(ScheduledV1 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
}),
|
||||
];
|
||||
@@ -1653,7 +1661,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: None,
|
||||
priority: 10,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
maybe_periodic: None,
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1662,7 +1670,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1675,7 +1683,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: None,
|
||||
priority: 11,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
maybe_periodic: None,
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1684,7 +1692,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1697,7 +1705,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: None,
|
||||
priority: 12,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
maybe_periodic: None,
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1706,7 +1714,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
origin: root(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1729,7 +1737,7 @@ mod tests {
|
||||
Some(Scheduled {
|
||||
maybe_id: None,
|
||||
priority: i as u8 + 10,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
origin: 3u32,
|
||||
maybe_periodic: None,
|
||||
_phantom: Default::default(),
|
||||
@@ -1739,7 +1747,7 @@ mod tests {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
origin: 2u32,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
_phantom: Default::default(),
|
||||
}),
|
||||
@@ -1768,7 +1776,7 @@ mod tests {
|
||||
Some(ScheduledV2::<_, _, OriginCaller, u64> {
|
||||
maybe_id: None,
|
||||
priority: 10,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
maybe_periodic: None,
|
||||
origin: system::RawOrigin::Root.into(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1777,7 +1785,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
origin: system::RawOrigin::None.into(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1790,7 +1798,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: None,
|
||||
priority: 11,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
maybe_periodic: None,
|
||||
origin: system::RawOrigin::Root.into(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1799,7 +1807,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
origin: system::RawOrigin::None.into(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1812,7 +1820,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: None,
|
||||
priority: 12,
|
||||
call: Call::Logger(LoggerCall::log(96, 100)),
|
||||
call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }),
|
||||
maybe_periodic: None,
|
||||
origin: system::RawOrigin::Root.into(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
@@ -1821,7 +1829,7 @@ mod tests {
|
||||
Some(ScheduledV2 {
|
||||
maybe_id: Some(b"test".to_vec()),
|
||||
priority: 123,
|
||||
call: Call::Logger(LoggerCall::log(69, 1000)),
|
||||
call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }),
|
||||
maybe_periodic: Some((456u64, 10)),
|
||||
origin: system::RawOrigin::None.into(),
|
||||
_phantom: PhantomData::<u64>::default(),
|
||||
|
||||
Reference in New Issue
Block a user