123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925 |
- #![cfg(test)]
- use frame_support::traits::{LockIdentifier, OnFinalize, OnInitialize};
- use frame_support::{
- impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types, weights::Weight,
- };
- pub use frame_system;
- use frame_system::{EnsureOneOf, EnsureRoot, EnsureSigned};
- use sp_core::H256;
- use sp_runtime::curve::PiecewiseLinear;
- use sp_runtime::{
- testing::Header,
- traits::{BlakeTwo256, IdentityLookup},
- DispatchResult, Perbill,
- };
- use sp_staking::SessionIndex;
- use staking_handler::{LockComparator, StakingManager};
- use crate::{ProposalDetailsOf, ProposalEncoder, ProposalParameters};
- use frame_support::dispatch::DispatchError;
- use proposals_engine::VotersParameters;
- use sp_runtime::testing::TestXt;
- impl_outer_origin! {
- pub enum Origin for Test {}
- }
- // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
- #[derive(Clone, PartialEq, Eq, Debug)]
- pub struct Test;
- parameter_types! {
- pub const BlockHashCount: u64 = 250;
- pub const MaximumBlockWeight: u32 = 1024;
- pub const MaximumBlockLength: u32 = 2 * 1024;
- pub const AvailableBlockRatio: Perbill = Perbill::one();
- pub const MinimumPeriod: u64 = 5;
- pub const InvitedMemberLockId: [u8; 8] = [2; 8];
- }
- mod proposals_codex_mod {
- pub use crate::Event;
- }
- impl_outer_event! {
- pub enum TestEvent for Test {
- proposals_codex_mod<T>,
- frame_system<T>,
- balances<T>,
- staking<T>,
- council<T>,
- proposals_discussion<T>,
- proposals_engine<T>,
- referendum Instance0 <T>,
- membership<T>,
- working_group Instance0 <T>,
- working_group Instance1 <T>,
- working_group Instance2 <T>,
- working_group Instance3 <T>,
- working_group Instance4 <T>,
- }
- }
- impl_outer_dispatch! {
- pub enum Call for Test where origin: Origin {
- codex::ProposalCodex,
- proposals::ProposalsEngine,
- staking::Staking,
- frame_system::System,
- }
- }
- impl common::Trait for Test {
- type MemberId = u64;
- type ActorId = u64;
- }
- // Weights info stub
- pub struct Weights;
- impl membership::WeightInfo for Weights {
- fn buy_membership_without_referrer(_: u32, _: u32, _: u32, _: u32) -> Weight {
- unimplemented!()
- }
- fn buy_membership_with_referrer(_: u32, _: u32, _: u32, _: u32) -> Weight {
- unimplemented!()
- }
- fn update_profile(_: u32) -> Weight {
- unimplemented!()
- }
- fn update_accounts_none() -> Weight {
- unimplemented!()
- }
- fn update_accounts_root() -> Weight {
- unimplemented!()
- }
- fn update_accounts_controller() -> Weight {
- unimplemented!()
- }
- fn update_accounts_both() -> Weight {
- unimplemented!()
- }
- fn set_referral_cut() -> Weight {
- unimplemented!()
- }
- fn transfer_invites() -> Weight {
- unimplemented!()
- }
- fn invite_member(_: u32, _: u32, _: u32, _: u32) -> Weight {
- unimplemented!()
- }
- fn set_membership_price() -> Weight {
- unimplemented!()
- }
- fn update_profile_verification() -> Weight {
- unimplemented!()
- }
- fn set_leader_invitation_quota() -> Weight {
- unimplemented!()
- }
- fn set_initial_invitation_balance() -> Weight {
- unimplemented!()
- }
- fn set_initial_invitation_count() -> Weight {
- unimplemented!()
- }
- fn add_staking_account_candidate() -> Weight {
- unimplemented!()
- }
- fn confirm_staking_account() -> Weight {
- unimplemented!()
- }
- fn remove_staking_account() -> Weight {
- unimplemented!()
- }
- }
- impl membership::Trait for Test {
- type Event = TestEvent;
- type DefaultMembershipPrice = DefaultMembershipPrice;
- type WorkingGroup = ();
- type WeightInfo = Weights;
- type DefaultInitialInvitationBalance = ();
- type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
- }
- impl common::working_group::WorkingGroupBudgetHandler<Test> for () {
- fn get_budget() -> u64 {
- unimplemented!()
- }
- fn set_budget(_new_value: u64) {
- unimplemented!()
- }
- }
- impl common::working_group::WorkingGroupAuthenticator<Test> for () {
- fn ensure_worker_origin(
- _origin: <Test as frame_system::Trait>::Origin,
- _worker_id: &<Test as common::Trait>::ActorId,
- ) -> DispatchResult {
- unimplemented!();
- }
- fn ensure_leader_origin(_origin: <Test as frame_system::Trait>::Origin) -> DispatchResult {
- unimplemented!()
- }
- fn get_leader_member_id() -> Option<<Test as common::Trait>::MemberId> {
- unimplemented!();
- }
- fn is_leader_account_id(_account_id: &<Test as frame_system::Trait>::AccountId) -> bool {
- unimplemented!()
- }
- fn is_worker_account_id(
- _account_id: &<Test as frame_system::Trait>::AccountId,
- _worker_id: &<Test as common::Trait>::ActorId,
- ) -> bool {
- unimplemented!()
- }
- }
- parameter_types! {
- pub const DefaultMembershipPrice: u64 = 100;
- pub const ExistentialDeposit: u32 = 0;
- pub const DefaultInitialInvitationBalance: u64 = 100;
- }
- impl balances::Trait for Test {
- type Balance = u64;
- type DustRemoval = ();
- type Event = TestEvent;
- type ExistentialDeposit = ExistentialDeposit;
- type AccountStore = System;
- type WeightInfo = ();
- type MaxLocks = ();
- }
- parameter_types! {
- pub const CancellationFee: u64 = 5;
- pub const RejectionFee: u64 = 3;
- pub const TitleMaxLength: u32 = 100;
- pub const DescriptionMaxLength: u32 = 10000;
- pub const MaxActiveProposalLimit: u32 = 100;
- pub const LockId: LockIdentifier = [2; 8];
- }
- pub struct MockProposalsEngineWeight;
- impl proposals_engine::Trait for Test {
- type Event = TestEvent;
- type ProposerOriginValidator = ();
- type CouncilOriginValidator = ();
- type TotalVotersCounter = MockVotersParameters;
- type ProposalId = u32;
- type StakingHandler = StakingManager<Test, LockId>;
- type CancellationFee = CancellationFee;
- type RejectionFee = RejectionFee;
- type TitleMaxLength = TitleMaxLength;
- type DescriptionMaxLength = DescriptionMaxLength;
- type MaxActiveProposalLimit = MaxActiveProposalLimit;
- type DispatchableCallCode = crate::Call<Test>;
- type ProposalObserver = crate::Module<Test>;
- type WeightInfo = MockProposalsEngineWeight;
- }
- impl proposals_engine::WeightInfo for MockProposalsEngineWeight {
- fn vote(_: u32) -> Weight {
- 0
- }
- fn cancel_proposal() -> Weight {
- 0
- }
- fn veto_proposal() -> Weight {
- 0
- }
- fn on_initialize_immediate_execution_decode_fails(_: u32) -> Weight {
- 0
- }
- fn on_initialize_pending_execution_decode_fails(_: u32) -> Weight {
- 0
- }
- fn on_initialize_approved_pending_constitutionality(_: u32) -> Weight {
- 0
- }
- fn on_initialize_rejected(_: u32) -> Weight {
- 0
- }
- fn on_initialize_slashed(_: u32) -> Weight {
- 0
- }
- fn cancel_active_and_pending_proposals(_: u32) -> u64 {
- 0
- }
- }
- impl Default for crate::Call<Test> {
- fn default() -> Self {
- panic!("shouldn't call default for Call");
- }
- }
- impl common::origin::MemberOriginValidator<Origin, u64, u64> for () {
- fn ensure_member_controller_account_origin(
- origin: Origin,
- _: u64,
- ) -> Result<u64, DispatchError> {
- let account_id = frame_system::ensure_signed(origin)?;
- Ok(account_id)
- }
- fn is_member_controller_account(member_id: &u64, account_id: &u64) -> bool {
- member_id == account_id
- }
- }
- impl common::origin::CouncilOriginValidator<Origin, u64, u64> for () {
- fn ensure_member_consulate(origin: Origin, _: u64) -> DispatchResult {
- frame_system::ensure_signed(origin)?;
- Ok(())
- }
- }
- parameter_types! {
- pub const ThreadTitleLengthLimit: u32 = 200;
- pub const PostLengthLimit: u32 = 2000;
- pub const MaxWhiteListSize: u32 = 20;
- }
- pub struct MockProposalsDiscussionWeight;
- impl proposals_discussion::Trait for Test {
- type Event = TestEvent;
- type AuthorOriginValidator = ();
- type CouncilOriginValidator = ();
- type ThreadId = u64;
- type PostId = u64;
- type MaxWhiteListSize = MaxWhiteListSize;
- type WeightInfo = MockProposalsDiscussionWeight;
- }
- impl proposals_discussion::WeightInfo for MockProposalsDiscussionWeight {
- fn add_post(_: u32) -> Weight {
- 0
- }
- fn update_post() -> Weight {
- 0
- }
- fn change_thread_mode(_: u32) -> Weight {
- 0
- }
- }
- pub struct MockVotersParameters;
- impl VotersParameters for MockVotersParameters {
- fn total_voters_count() -> u32 {
- 4
- }
- }
- // The forum working group instance alias.
- pub type ForumWorkingGroupInstance = working_group::Instance1;
- // The storage working group instance alias.
- pub type StorageWorkingGroupInstance = working_group::Instance2;
- // The content directory working group instance alias.
- pub type ContentDirectoryWorkingGroupInstance = working_group::Instance3;
- // The membership working group instance alias.
- pub type MembershipWorkingGroupInstance = working_group::Instance4;
- parameter_types! {
- pub const MaxWorkerNumberLimit: u32 = 100;
- pub const LockId1: [u8; 8] = [1; 8];
- pub const LockId2: [u8; 8] = [2; 8];
- }
- pub struct WorkingGroupWeightInfo;
- impl working_group::Trait<ContentDirectoryWorkingGroupInstance> for Test {
- type Event = TestEvent;
- type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
- type StakingHandler = StakingManager<Self, LockId1>;
- type StakingAccountValidator = membership::Module<Test>;
- type MemberOriginValidator = ();
- type MinUnstakingPeriodLimit = ();
- type RewardPeriod = ();
- type WeightInfo = WorkingGroupWeightInfo;
- }
- impl working_group::WeightInfo for WorkingGroupWeightInfo {
- fn on_initialize_leaving(_: u32) -> Weight {
- 0
- }
- fn on_initialize_rewarding_with_missing_reward(_: u32) -> Weight {
- 0
- }
- fn on_initialize_rewarding_with_missing_reward_cant_pay(_: u32) -> Weight {
- 0
- }
- fn on_initialize_rewarding_without_missing_reward(_: u32) -> Weight {
- 0
- }
- fn apply_on_opening(_: u32) -> Weight {
- 0
- }
- fn fill_opening_lead() -> Weight {
- 0
- }
- fn fill_opening_worker(_: u32) -> Weight {
- 0
- }
- fn update_role_account() -> Weight {
- 0
- }
- fn cancel_opening() -> Weight {
- 0
- }
- fn withdraw_application() -> Weight {
- 0
- }
- fn slash_stake(_: u32) -> Weight {
- 0
- }
- fn terminate_role_worker(_: u32) -> Weight {
- 0
- }
- fn terminate_role_lead(_: u32) -> Weight {
- 0
- }
- fn increase_stake() -> Weight {
- 0
- }
- fn decrease_stake() -> Weight {
- 0
- }
- fn spend_from_budget() -> Weight {
- 0
- }
- fn update_reward_amount() -> Weight {
- 0
- }
- fn set_status_text(_: u32) -> Weight {
- 0
- }
- fn update_reward_account() -> Weight {
- 0
- }
- fn set_budget() -> Weight {
- 0
- }
- fn add_opening(_: u32) -> Weight {
- 0
- }
- fn leave_role_immediatly() -> Weight {
- 0
- }
- fn leave_role_later() -> Weight {
- 0
- }
- }
- impl working_group::Trait<StorageWorkingGroupInstance> for Test {
- type Event = TestEvent;
- type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
- type StakingHandler = StakingManager<Self, LockId2>;
- type StakingAccountValidator = membership::Module<Test>;
- type MemberOriginValidator = ();
- type MinUnstakingPeriodLimit = ();
- type RewardPeriod = ();
- type WeightInfo = WorkingGroupWeightInfo;
- }
- impl working_group::Trait<ForumWorkingGroupInstance> for Test {
- type Event = TestEvent;
- type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
- type StakingHandler = staking_handler::StakingManager<Self, LockId2>;
- type StakingAccountValidator = membership::Module<Test>;
- type MemberOriginValidator = ();
- type MinUnstakingPeriodLimit = ();
- type RewardPeriod = ();
- type WeightInfo = WorkingGroupWeightInfo;
- }
- impl working_group::Trait<MembershipWorkingGroupInstance> for Test {
- type Event = TestEvent;
- type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
- type StakingHandler = StakingManager<Self, LockId2>;
- type StakingAccountValidator = membership::Module<Test>;
- type MemberOriginValidator = ();
- type MinUnstakingPeriodLimit = ();
- type RewardPeriod = ();
- type WeightInfo = WorkingGroupWeightInfo;
- }
- pallet_staking_reward_curve::build! {
- const I_NPOS: PiecewiseLinear<'static> = curve!(
- min_inflation: 0_025_000,
- max_inflation: 0_100_000,
- ideal_stake: 0_500_000,
- falloff: 0_050_000,
- max_piece_count: 40,
- test_precision: 0_005_000,
- );
- }
- parameter_types! {
- pub const SessionsPerEra: SessionIndex = 3;
- pub const BondingDuration: staking::EraIndex = 3;
- pub const RewardCurve: &'static PiecewiseLinear<'static> = &I_NPOS;
- }
- impl staking::Trait for Test {
- type Currency = Balances;
- type UnixTime = Timestamp;
- type CurrencyToVote = ();
- type RewardRemainder = ();
- type Event = TestEvent;
- type Slash = ();
- type Reward = ();
- type SessionsPerEra = SessionsPerEra;
- type BondingDuration = BondingDuration;
- type SlashDeferDuration = ();
- type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
- type SessionInterface = Self;
- type RewardCurve = RewardCurve;
- type NextNewSession = ();
- type ElectionLookahead = ();
- type Call = Call;
- type MaxIterations = ();
- type MinSolutionScoreBump = ();
- type MaxNominatorRewardedPerValidator = ();
- type UnsignedPriority = ();
- type WeightInfo = ();
- }
- impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Test
- where
- Call: From<LocalCall>,
- {
- type OverarchingCall = Call;
- type Extrinsic = Extrinsic;
- }
- pub type Extrinsic = TestXt<Call, ()>;
- impl staking::SessionInterface<u64> for Test {
- fn disable_validator(_: &u64) -> Result<bool, ()> {
- unimplemented!()
- }
- fn validators() -> Vec<u64> {
- unimplemented!()
- }
- fn prune_historical_up_to(_: u32) {
- unimplemented!()
- }
- }
- parameter_types! {
- pub DefaultProposalParameters: ProposalParameters<u64, u64> = default_proposal_parameters();
- }
- pub(crate) fn default_proposal_parameters() -> ProposalParameters<u64, u64> {
- ProposalParameters {
- voting_period: 43200,
- grace_period: 0,
- approval_quorum_percentage: 66,
- approval_threshold_percentage: 80,
- slashing_quorum_percentage: 60,
- slashing_threshold_percentage: 80,
- required_stake: Some(100_000),
- constitutionality: 1,
- }
- }
- impl crate::Trait for Test {
- type Event = TestEvent;
- type MembershipOriginValidator = ();
- type ProposalEncoder = ();
- type WeightInfo = ();
- type SetMaxValidatorCountProposalParameters = DefaultProposalParameters;
- type RuntimeUpgradeProposalParameters = DefaultProposalParameters;
- type SignalProposalParameters = DefaultProposalParameters;
- type FundingRequestProposalParameters = DefaultProposalParameters;
- type CreateWorkingGroupLeadOpeningProposalParameters = DefaultProposalParameters;
- type FillWorkingGroupLeadOpeningProposalParameters = DefaultProposalParameters;
- type UpdateWorkingGroupBudgetProposalParameters = DefaultProposalParameters;
- type DecreaseWorkingGroupLeadStakeProposalParameters = DefaultProposalParameters;
- type SlashWorkingGroupLeadProposalParameters = DefaultProposalParameters;
- type SetWorkingGroupLeadRewardProposalParameters = DefaultProposalParameters;
- type TerminateWorkingGroupLeadProposalParameters = DefaultProposalParameters;
- type AmendConstitutionProposalParameters = DefaultProposalParameters;
- type CancelWorkingGroupLeadOpeningProposalParameters = DefaultProposalParameters;
- type SetMembershipPriceProposalParameters = DefaultProposalParameters;
- type SetCouncilBudgetIncrementProposalParameters = DefaultProposalParameters;
- type SetCouncilorRewardProposalParameters = DefaultProposalParameters;
- type SetInitialInvitationBalanceProposalParameters = DefaultProposalParameters;
- type SetInvitationCountProposalParameters = DefaultProposalParameters;
- type SetMembershipLeadInvitationQuotaProposalParameters = DefaultProposalParameters;
- type SetReferralCutProposalParameters = DefaultProposalParameters;
- type CreateBlogPostProposalParameters = DefaultProposalParameters;
- type EditBlogPostProoposalParamters = DefaultProposalParameters;
- type LockBlogPostProposalParameters = DefaultProposalParameters;
- type UnlockBlogPostProposalParameters = DefaultProposalParameters;
- type VetoProposalProposalParameters = DefaultProposalParameters;
- }
- parameter_types! {
- pub const MinNumberOfExtraCandidates: u64 = 1;
- pub const AnnouncingPeriodDuration: u64 = 15;
- pub const IdlePeriodDuration: u64 = 27;
- pub const CouncilSize: u64 = 3;
- pub const MinCandidateStake: u64 = 11000;
- pub const CandidacyLockId: LockIdentifier = *b"council1";
- pub const CouncilorLockId: LockIdentifier = *b"council2";
- pub const ElectedMemberRewardPeriod: u64 = 10;
- pub const BudgetRefillAmount: u64 = 1000;
- // intentionally high number that prevents side-effecting tests other than budget refill tests
- pub const BudgetRefillPeriod: u64 = 1000;
- }
- pub type ReferendumInstance = referendum::Instance0;
- impl council::Trait for Test {
- type Event = TestEvent;
- type Referendum = referendum::Module<Test, ReferendumInstance>;
- type MinNumberOfExtraCandidates = MinNumberOfExtraCandidates;
- type CouncilSize = CouncilSize;
- type AnnouncingPeriodDuration = AnnouncingPeriodDuration;
- type IdlePeriodDuration = IdlePeriodDuration;
- type MinCandidateStake = MinCandidateStake;
- type CandidacyLock = StakingManager<Self, CandidacyLockId>;
- type CouncilorLock = StakingManager<Self, CouncilorLockId>;
- type ElectedMemberRewardPeriod = ElectedMemberRewardPeriod;
- type BudgetRefillPeriod = BudgetRefillPeriod;
- type StakingAccountValidator = ();
- type WeightInfo = CouncilWeightInfo;
- fn new_council_elected(_: &[council::CouncilMemberOf<Self>]) {}
- type MemberOriginValidator = ();
- }
- impl common::StakingAccountValidator<Test> for () {
- fn is_member_staking_account(_: &u64, _: &u64) -> bool {
- true
- }
- }
- pub struct CouncilWeightInfo;
- impl council::WeightInfo for CouncilWeightInfo {
- fn try_process_budget() -> Weight {
- 0
- }
- fn try_progress_stage_idle() -> Weight {
- 0
- }
- fn try_progress_stage_announcing_start_election(_: u32) -> Weight {
- 0
- }
- fn try_progress_stage_announcing_restart() -> Weight {
- 0
- }
- fn announce_candidacy() -> Weight {
- 0
- }
- fn release_candidacy_stake() -> Weight {
- 0
- }
- fn set_candidacy_note(_: u32) -> Weight {
- 0
- }
- fn withdraw_candidacy() -> Weight {
- 0
- }
- fn set_budget() -> Weight {
- 0
- }
- fn plan_budget_refill() -> Weight {
- 0
- }
- fn set_budget_increment() -> Weight {
- 0
- }
- fn set_councilor_reward() -> Weight {
- 0
- }
- fn funding_request(_: u32) -> Weight {
- 0
- }
- }
- parameter_types! {
- pub const VoteStageDuration: u64 = 19;
- pub const RevealStageDuration: u64 = 23;
- pub const MinimumVotingStake: u64 = 10000;
- pub const MaxSaltLength: u64 = 32; // use some multiple of 8 for ez testing
- pub const VotingLockId: LockIdentifier = *b"referend";
- pub const MaxWinnerTargetCount: u64 = 10;
- }
- impl referendum::Trait<ReferendumInstance> for Test {
- type Event = TestEvent;
- type MaxSaltLength = MaxSaltLength;
- type StakingHandler = staking_handler::StakingManager<Self, VotingLockId>;
- type ManagerOrigin =
- EnsureOneOf<Self::AccountId, EnsureSigned<Self::AccountId>, EnsureRoot<Self::AccountId>>;
- type VotePower = u64;
- type VoteStageDuration = VoteStageDuration;
- type RevealStageDuration = RevealStageDuration;
- type MinimumStake = MinimumVotingStake;
- type WeightInfo = ReferendumWeightInfo;
- type MaxWinnerTargetCount = MaxWinnerTargetCount;
- fn calculate_vote_power(
- _: &<Self as frame_system::Trait>::AccountId,
- _: &Self::Balance,
- ) -> Self::VotePower {
- 1
- }
- fn can_unlock_vote_stake(
- _: &referendum::CastVote<Self::Hash, Self::Balance, Self::MemberId>,
- ) -> bool {
- true
- }
- fn process_results(winners: &[referendum::OptionResult<Self::MemberId, Self::VotePower>]) {
- let tmp_winners: Vec<referendum::OptionResult<Self::MemberId, Self::VotePower>> = winners
- .iter()
- .map(|item| referendum::OptionResult {
- option_id: item.option_id,
- vote_power: item.vote_power.into(),
- })
- .collect();
- <council::Module<Test> as council::ReferendumConnection<Test>>::recieve_referendum_results(
- tmp_winners.as_slice(),
- );
- }
- fn is_valid_option_id(option_index: &u64) -> bool {
- <council::Module<Test> as council::ReferendumConnection<Test>>::is_valid_candidate_id(
- option_index,
- )
- }
- fn get_option_power(option_id: &u64) -> Self::VotePower {
- <council::Module<Test> as council::ReferendumConnection<Test>>::get_option_power(option_id)
- }
- fn increase_option_power(option_id: &u64, amount: &Self::VotePower) {
- <council::Module<Test> as council::ReferendumConnection<Test>>::increase_option_power(
- option_id, amount,
- );
- }
- }
- pub struct ReferendumWeightInfo;
- impl referendum::WeightInfo for ReferendumWeightInfo {
- fn on_initialize_revealing(_: u32) -> Weight {
- 0
- }
- fn on_initialize_voting() -> Weight {
- 0
- }
- fn vote() -> Weight {
- 0
- }
- fn reveal_vote_space_for_new_winner(_: u32) -> Weight {
- 0
- }
- fn reveal_vote_space_not_in_winners(_: u32) -> Weight {
- 0
- }
- fn reveal_vote_space_replace_last_winner(_: u32) -> Weight {
- 0
- }
- fn reveal_vote_already_existing(_: u32) -> Weight {
- 0
- }
- fn release_vote_stake() -> Weight {
- 0
- }
- }
- impl crate::WeightInfo for () {
- fn create_proposal_signal(_: u32, _: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_runtime_upgrade(_: u32, _: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_funding_request(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_set_max_validator_count(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_create_working_group_lead_opening(_: u32, _: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_fill_working_group_lead_opening(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_update_working_group_budget(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_decrease_working_group_lead_stake(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_slash_working_group_lead(_: u32) -> Weight {
- 0
- }
- fn create_proposal_set_working_group_lead_reward(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_terminate_working_group_lead(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_amend_constitution(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_cancel_working_group_lead_opening(_: u32) -> Weight {
- 0
- }
- fn create_proposal_set_membership_price(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_set_council_budget_increment(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_set_councilor_reward(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_set_initial_invitation_balance(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_set_initial_invitation_count(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_set_membership_lead_invitation_quota(_: u32) -> Weight {
- 0
- }
- fn create_proposal_set_referral_cut(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_create_blog_post(_: u32, _: u32, _: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_edit_blog_post(_: u32, _: u32, _: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_lock_blog_post(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_unlock_blog_post(_: u32, _: u32) -> Weight {
- 0
- }
- fn create_proposal_veto_proposal(_: u32, _: u32) -> Weight {
- 0
- }
- }
- impl ProposalEncoder<Test> for () {
- fn encode_proposal(_proposal_details: ProposalDetailsOf<Test>) -> Vec<u8> {
- Vec::new()
- }
- }
- impl frame_system::Trait for Test {
- type BaseCallFilter = ();
- type Origin = Origin;
- type Call = Call;
- type Index = u64;
- type BlockNumber = u64;
- type Hash = H256;
- type Hashing = BlakeTwo256;
- type AccountId = u64;
- type Lookup = IdentityLookup<Self::AccountId>;
- type Header = Header;
- type Event = TestEvent;
- type BlockHashCount = BlockHashCount;
- type MaximumBlockWeight = MaximumBlockWeight;
- type DbWeight = ();
- type BlockExecutionWeight = ();
- type ExtrinsicBaseWeight = ();
- type MaximumExtrinsicWeight = ();
- type MaximumBlockLength = MaximumBlockLength;
- type AvailableBlockRatio = AvailableBlockRatio;
- type Version = ();
- type PalletInfo = ();
- type AccountData = balances::AccountData<u64>;
- type OnNewAccount = ();
- type OnKilledAccount = ();
- type SystemWeightInfo = ();
- }
- impl pallet_timestamp::Trait for Test {
- type Moment = u64;
- type OnTimestampSet = ();
- type MinimumPeriod = MinimumPeriod;
- type WeightInfo = ();
- }
- impl LockComparator<<Test as balances::Trait>::Balance> for Test {
- fn are_locks_conflicting(
- _new_lock: &LockIdentifier,
- _existing_locks: &[LockIdentifier],
- ) -> bool {
- false
- }
- }
- pub fn initial_test_ext() -> sp_io::TestExternalities {
- let t = frame_system::GenesisConfig::default()
- .build_storage::<Test>()
- .unwrap();
- let mut result = Into::<sp_io::TestExternalities>::into(t.clone());
- // Make sure we are not in block 1 where no events are emitted
- // see https://substrate.dev/recipes/2-appetizers/4-events.html#emitting-events
- result.execute_with(|| {
- let mut block_number = frame_system::Module::<Test>::block_number();
- <System as OnFinalize<u64>>::on_finalize(block_number);
- block_number = block_number + 1;
- System::set_block_number(block_number);
- <System as OnInitialize<u64>>::on_initialize(block_number);
- });
- result
- }
- pub type Staking = staking::Module<Test>;
- pub type ProposalCodex = crate::Module<Test>;
- pub type ProposalsEngine = proposals_engine::Module<Test>;
- pub type Balances = balances::Module<Test>;
- pub type Timestamp = pallet_timestamp::Module<Test>;
- pub type System = frame_system::Module<Test>;
|