Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Migrate pallet-democracy to pallet attribute macro #8824

Merged
4 commits merged into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ construct_runtime!(
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>},
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
Elections: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>},
Expand Down
15 changes: 7 additions & 8 deletions frame/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ use super::*;

use frame_benchmarking::{benchmarks, account, whitelist_account, impl_benchmark_test_suite};
use frame_support::{
assert_noop, assert_ok, IterableStorageMap,
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable,
schedule::DispatchTime},
assert_noop, assert_ok,
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime},
};
use frame_system::{RawOrigin, Pallet as System, self};
use sp_runtime::traits::{Bounded, One};
Expand Down Expand Up @@ -69,13 +68,13 @@ fn add_referendum<T: Config>(n: u32) -> Result<ReferendumIndex, &'static str> {
vote_threshold,
0u32.into(),
);
let referendum_index: ReferendumIndex = ReferendumCount::get() - 1;
let referendum_index: ReferendumIndex = ReferendumCount::<T>::get() - 1;
T::Scheduler::schedule_named(
(DEMOCRACY_ID, referendum_index).encode(),
DispatchTime::At(1u32.into()),
None,
63,
system::RawOrigin::Root.into(),
frame_system::RawOrigin::Root.into(),
Call::enact_proposal(proposal_hash, referendum_index).into(),
).map_err(|_| "failed to schedule named")?;
Ok(referendum_index)
Expand Down Expand Up @@ -360,7 +359,7 @@ benchmarks! {
assert_eq!(Democracy::<T>::referendum_count(), r, "referenda not created");

// Launch external
LastTabledWasExternal::put(false);
LastTabledWasExternal::<T>::put(false);

let origin = T::ExternalMajorityOrigin::successful_origin();
let proposal_hash = T::Hashing::hash_of(&r);
Expand Down Expand Up @@ -402,7 +401,7 @@ benchmarks! {

// Launch public
assert!(add_proposal::<T>(r).is_ok(), "proposal not created");
LastTabledWasExternal::put(true);
LastTabledWasExternal::<T>::put(true);

let block_number = T::LaunchPeriod::get();

Expand Down Expand Up @@ -760,7 +759,7 @@ benchmarks! {
}: enact_proposal(RawOrigin::Root, proposal_hash, 0)
verify {
// Fails due to mismatched origin
assert_last_event::<T>(RawEvent::Executed(0, false).into());
assert_last_event::<T>(Event::<T>::Executed(0, false).into());
}

#[extra]
Expand Down
Loading