mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +00:00
Introduce scheduler and use it for the democracy dispatch queue (#5412)
* Initial draft of the logic * Build and tests * Make work with new initialize infratructure. * Update frame/scheduler/src/lib.rs Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com> * Update frame/scheduler/src/lib.rs Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com> * Update frame/scheduler/src/lib.rs Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com> * Update frame/scheduler/src/lib.rs Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com> * Fix test * Update frame/scheduler/src/lib.rs Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com> * Rejig interface to make it more useful for democracy. * Try to get democraxy module to make use of scheduler. * Make democracy use scheduler. * Use actual max weight for enactent * Remove TODO * Fix runtime build * Minor cleanup * Fix scheduler. * Fix benchmarks * Fix * Fix * Fix * More bench fixes * Fix * Fix. * Add more bench constants. * Fix cancel_queued bench. * Fix test comment. * Update frame/scheduler/src/lib.rs Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com> Co-authored-by: Marcio Diaz <marcio.diaz@gmail.com>
This commit is contained in:
@@ -21,7 +21,7 @@ use std::cell::RefCell;
|
||||
use codec::Encode;
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types,
|
||||
ord_parameter_types, traits::Contains, weights::Weight,
|
||||
ord_parameter_types, traits::{Contains, OnInitialize}, weights::Weight,
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
@@ -71,7 +71,7 @@ impl frame_system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Call = ();
|
||||
type Call = Call;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
@@ -90,6 +90,13 @@ impl frame_system::Trait for Test {
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 1;
|
||||
pub const MaximumWeight: u32 = 1000000;
|
||||
}
|
||||
impl pallet_scheduler::Trait for Test {
|
||||
type Event = ();
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type MaximumWeight = MaximumWeight;
|
||||
}
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
@@ -152,6 +159,7 @@ impl super::Trait for Test {
|
||||
type Slash = ();
|
||||
type InstantOrigin = EnsureSignedBy<Six, u64>;
|
||||
type InstantAllowed = InstantAllowed;
|
||||
type Scheduler = Scheduler;
|
||||
}
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
@@ -167,6 +175,7 @@ fn new_test_ext() -> sp_io::TestExternalities {
|
||||
|
||||
type System = frame_system::Module<Test>;
|
||||
type Balances = pallet_balances::Module<Test>;
|
||||
type Scheduler = pallet_scheduler::Module<Test>;
|
||||
type Democracy = Module<Test>;
|
||||
|
||||
#[test]
|
||||
@@ -215,6 +224,7 @@ fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> DispatchRes
|
||||
|
||||
fn next_block() {
|
||||
System::set_block_number(System::block_number() + 1);
|
||||
Scheduler::on_initialize(System::block_number());
|
||||
assert_eq!(Democracy::begin_block(System::block_number()), Ok(()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user