Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable2409] Backport #5311 #6805

Merged
merged 1 commit into from
Dec 10, 2024
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
16 changes: 16 additions & 0 deletions prdoc/pr_5311.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: No-op Impl Polling Trait

doc:
- audience: Runtime Dev
description: |
Provide a NoOp implementation of the Polling trait for unit where the trait is defined and skiping benchmarks that necessitate it's definition.

crates:
- name: pallet-core-fellowship
bump: minor
- name: pallet-ranked-collective
bump: minor
- name: pallet-salary
bump: minor
- name: frame-support
bump: minor
47 changes: 4 additions & 43 deletions substrate/frame/core-fellowship/src/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ use frame_support::{
assert_noop, assert_ok, derive_impl, hypothetically, ord_parameter_types,
pallet_prelude::Weight,
parameter_types,
traits::{ConstU16, EitherOf, IsInVec, MapSuccess, PollStatus, Polling, TryMapSuccess},
traits::{ConstU16, EitherOf, IsInVec, MapSuccess, NoOpPoll, TryMapSuccess},
};
use frame_system::EnsureSignedBy;
use pallet_ranked_collective::{EnsureRanked, Geometric, Rank, TallyOf, Votes};
use pallet_ranked_collective::{EnsureRanked, Geometric, Rank};
use sp_core::{ConstU32, Get};
use sp_runtime::{
bounded_vec,
traits::{Convert, ReduceBy, ReplaceWithDefault, TryMorphInto},
BuildStorage, DispatchError,
BuildStorage,
};
type Class = Rank;

Expand Down Expand Up @@ -83,45 +83,6 @@ impl Config for Test {
type MaxRank = ConstU32<9>;
}

pub struct TestPolls;
impl Polling<TallyOf<Test>> for TestPolls {
type Index = u8;
type Votes = Votes;
type Moment = u64;
type Class = Class;

fn classes() -> Vec<Self::Class> {
unimplemented!()
}
fn as_ongoing(_: u8) -> Option<(TallyOf<Test>, Self::Class)> {
unimplemented!()
}
fn access_poll<R>(
_: Self::Index,
_: impl FnOnce(PollStatus<&mut TallyOf<Test>, Self::Moment, Self::Class>) -> R,
) -> R {
unimplemented!()
}
fn try_access_poll<R>(
_: Self::Index,
_: impl FnOnce(
PollStatus<&mut TallyOf<Test>, Self::Moment, Self::Class>,
) -> Result<R, DispatchError>,
) -> Result<R, DispatchError> {
unimplemented!()
}

#[cfg(feature = "runtime-benchmarks")]
fn create_ongoing(_: Self::Class) -> Result<Self::Index, ()> {
unimplemented!()
}

#[cfg(feature = "runtime-benchmarks")]
fn end_ongoing(_: Self::Index, _: bool) -> Result<(), ()> {
unimplemented!()
}
}

/// Convert the tally class into the minimum rank required to vote on the poll.
/// MinRank(Class) = Class - Delta
pub struct MinRankOfClass<Delta>(PhantomData<Delta>);
Expand Down Expand Up @@ -154,7 +115,7 @@ impl pallet_ranked_collective::Config for Test {
// Members can exchange up to the rank of 2 below them.
MapSuccess<EnsureRanked<Test, (), 2>, ReduceBy<ConstU16<2>>>,
>;
type Polls = TestPolls;
type Polls = NoOpPoll;
type MinRankOfClass = MinRankOfClass<MinRankOfClassDelta>;
type MemberSwappedHandler = CoreFellowship;
type VoteWeight = Geometric;
Expand Down
Loading
Loading