difftreelog
ffeat: add new fns to test-utils pallet
in: master
3 files changed
Cargo.lockdiffbeforeafterboth6675dependencies = [6675dependencies = [6676 "frame-support",6676 "frame-support",6677 "frame-system",6677 "frame-system",6678 "pallet-unique-scheduler",6678 "parity-scale-codec 3.1.5",6679 "parity-scale-codec 3.1.5",6679 "scale-info",6680 "scale-info",6680]6681]test-pallets/utils/Cargo.tomldiffbeforeafterboth10scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }10scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }11frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }11frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }12frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }12frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }13pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }131414[features]15[features]15default = ["std"]16default = ["std"]18 "scale-info/std",19 "scale-info/std",19 "frame-support/std",20 "frame-support/std",20 "frame-system/std",21 "frame-system/std",22 "pallet-unique-scheduler/std",21]23]2224test-pallets/utils/src/lib.rsdiffbeforeafterboth22pub mod pallet {23pub mod pallet {23 use frame_support::pallet_prelude::*;24 use frame_support::pallet_prelude::*;24 use frame_system::pallet_prelude::*;25 use frame_system::pallet_prelude::*;26 use pallet_unique_scheduler::{ScheduledId, Pallet as SchedulerPallet};252726 #[pallet::config]28 #[pallet::config]27 pub trait Config: frame_system::Config {29 pub trait Config: frame_system::Config + pallet_unique_scheduler::Config {28 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;30 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;29 }31 }303240 pub struct Pallet<T>(_);42 pub struct Pallet<T>(_);414342 #[pallet::storage]44 #[pallet::storage]43 #[pallet::getter(fn something)]45 #[pallet::getter(fn test_value)]44 pub type TestValue<T> = StorageValue<_, u32, ValueQuery>;46 pub type TestValue<T> = StorageValue<_, u32, ValueQuery>;454746 #[pallet::error]48 #[pallet::error]70 Err(<Error<T>>::TriggerRollback.into())72 Err(<Error<T>>::TriggerRollback.into())71 }73 }7475 #[pallet::weight(10_000)]76 pub fn inc_test_value(origin: OriginFor<T>) -> DispatchResult {77 Self::set_test_value(origin, <TestValue<T>>::get() + 1)78 }7980 #[pallet::weight(10_000)]81 pub fn self_canceling_inc(82 origin: OriginFor<T>,83 id: ScheduledId,84 max_test_value: u32,85 ) -> DispatchResult {86 if <TestValue<T>>::get() < max_test_value {87 Self::inc_test_value(origin)?;88 } else {89 SchedulerPallet::<T>::cancel_named(origin, id)?;90 }9192 Ok(())93 }729473 #[pallet::weight(100_000_000)]95 #[pallet::weight(100_000_000)]74 pub fn just_take_fee(_origin: OriginFor<T>) -> DispatchResult {96 pub fn just_take_fee(_origin: OriginFor<T>) -> DispatchResult {