mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 07:31:08 +00:00
pallet-democracy: Do not request the proposal when scheduling (#13827)
The requesting of the proposal is actually done now in `pallet-scheduler`. Fixes: https://github.com/paritytech/substrate/issues/13534
This commit is contained in:
@@ -1606,11 +1606,6 @@ impl<T: Config> Pallet<T> {
|
|||||||
|
|
||||||
if approved {
|
if approved {
|
||||||
Self::deposit_event(Event::<T>::Passed { ref_index: index });
|
Self::deposit_event(Event::<T>::Passed { ref_index: index });
|
||||||
// Actually `hold` the proposal now since we didn't hold it when it came in via the
|
|
||||||
// submit extrinsic and we now know that it will be needed. This will be reversed by
|
|
||||||
// Scheduler pallet once it is executed which assumes that we will already have placed
|
|
||||||
// a `hold` on it.
|
|
||||||
T::Preimages::hold(&status.proposal);
|
|
||||||
|
|
||||||
// Earliest it can be scheduled for is next block.
|
// Earliest it can be scheduled for is next block.
|
||||||
let when = now.saturating_add(status.delay.max(One::one()));
|
let when = now.saturating_add(status.delay.max(One::one()));
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ fn set_external_metadata_works() {
|
|||||||
Error::<Test>::NoProposal,
|
Error::<Test>::NoProposal,
|
||||||
);
|
);
|
||||||
// create an external proposal.
|
// create an external proposal.
|
||||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),));
|
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2)));
|
||||||
assert!(<NextExternal<Test>>::exists());
|
assert!(<NextExternal<Test>>::exists());
|
||||||
// fails to set metadata with non external origin.
|
// fails to set metadata with non external origin.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
@@ -47,7 +47,7 @@ fn set_external_metadata_works() {
|
|||||||
);
|
);
|
||||||
// set metadata successful.
|
// set metadata successful.
|
||||||
let hash = note_preimage(1);
|
let hash = note_preimage(1);
|
||||||
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(hash),),);
|
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(hash)));
|
||||||
System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet {
|
System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet {
|
||||||
owner,
|
owner,
|
||||||
hash,
|
hash,
|
||||||
@@ -61,11 +61,11 @@ fn clear_metadata_works() {
|
|||||||
// metadata owner is an external proposal.
|
// metadata owner is an external proposal.
|
||||||
let owner = MetadataOwner::External;
|
let owner = MetadataOwner::External;
|
||||||
// create an external proposal.
|
// create an external proposal.
|
||||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),));
|
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2)));
|
||||||
assert!(<NextExternal<Test>>::exists());
|
assert!(<NextExternal<Test>>::exists());
|
||||||
// set metadata.
|
// set metadata.
|
||||||
let hash = note_preimage(1);
|
let hash = note_preimage(1);
|
||||||
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(hash),));
|
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(hash)));
|
||||||
// fails to clear metadata with a wrong origin.
|
// fails to clear metadata with a wrong origin.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None),
|
Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None),
|
||||||
@@ -92,18 +92,18 @@ fn set_proposal_metadata_works() {
|
|||||||
let owner = MetadataOwner::Proposal(Democracy::public_prop_count() - 1);
|
let owner = MetadataOwner::Proposal(Democracy::public_prop_count() - 1);
|
||||||
// fails to set non-existing preimage.
|
// fails to set non-existing preimage.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(invalid_hash),),
|
Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(invalid_hash)),
|
||||||
Error::<Test>::PreimageNotExist,
|
Error::<Test>::PreimageNotExist,
|
||||||
);
|
);
|
||||||
// note preimage.
|
// note preimage.
|
||||||
let hash = note_preimage(1);
|
let hash = note_preimage(1);
|
||||||
// fails to set a preimage if an origin is not a proposer.
|
// fails to set a preimage if an origin is not a proposer.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), Some(hash),),
|
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), Some(hash)),
|
||||||
Error::<Test>::NoPermission,
|
Error::<Test>::NoPermission,
|
||||||
);
|
);
|
||||||
// set metadata successful.
|
// set metadata successful.
|
||||||
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash),),);
|
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash)));
|
||||||
System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet {
|
System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet {
|
||||||
owner,
|
owner,
|
||||||
hash,
|
hash,
|
||||||
@@ -120,7 +120,7 @@ fn clear_proposal_metadata_works() {
|
|||||||
let owner = MetadataOwner::Proposal(Democracy::public_prop_count() - 1);
|
let owner = MetadataOwner::Proposal(Democracy::public_prop_count() - 1);
|
||||||
// set metadata.
|
// set metadata.
|
||||||
let hash = note_preimage(1);
|
let hash = note_preimage(1);
|
||||||
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash),));
|
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash)));
|
||||||
// fails to clear metadata with a wrong origin.
|
// fails to clear metadata with a wrong origin.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None),
|
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None),
|
||||||
@@ -150,16 +150,16 @@ fn set_referendum_metadata_by_root() {
|
|||||||
let hash = note_preimage(1);
|
let hash = note_preimage(1);
|
||||||
// fails to set if not a root.
|
// fails to set if not a root.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), Some(hash),),
|
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), Some(hash)),
|
||||||
Error::<Test>::NoPermission,
|
Error::<Test>::NoPermission,
|
||||||
);
|
);
|
||||||
// fails to clear if not a root.
|
// fails to clear if not a root.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None,),
|
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None),
|
||||||
Error::<Test>::NoPermission,
|
Error::<Test>::NoPermission,
|
||||||
);
|
);
|
||||||
// succeed to set metadata by a root for an ongoing referendum.
|
// succeed to set metadata by a root for an ongoing referendum.
|
||||||
assert_ok!(Democracy::set_metadata(RuntimeOrigin::root(), owner.clone(), Some(hash),));
|
assert_ok!(Democracy::set_metadata(RuntimeOrigin::root(), owner.clone(), Some(hash)));
|
||||||
System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet {
|
System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet {
|
||||||
owner: owner.clone(),
|
owner: owner.clone(),
|
||||||
hash,
|
hash,
|
||||||
|
|||||||
@@ -438,6 +438,8 @@ pub mod v3 {
|
|||||||
/// Schedule a dispatch to happen at the beginning of some block in the future.
|
/// Schedule a dispatch to happen at the beginning of some block in the future.
|
||||||
///
|
///
|
||||||
/// - `id`: The identity of the task. This must be unique and will return an error if not.
|
/// - `id`: The identity of the task. This must be unique and will return an error if not.
|
||||||
|
///
|
||||||
|
/// NOTE: This will request `call` to be made available.
|
||||||
fn schedule_named(
|
fn schedule_named(
|
||||||
id: TaskName,
|
id: TaskName,
|
||||||
when: DispatchTime<BlockNumber>,
|
when: DispatchTime<BlockNumber>,
|
||||||
|
|||||||
Reference in New Issue
Block a user