Further Improve Gov V2 Stuff (#12028)

* refactor and improve successful origin

* use appropriate origin for creating referendum

* fmt

* add setup tally feature for benchmarks

* feedback updates

* fmt

* Update frame/referenda/src/benchmarking.rs

Co-authored-by: Gavin Wood <gavin@parity.io>

* feedback on `setup` trait

* fix

Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
Shawn Tabrizi
2022-08-14 19:36:19 +01:00
committed by GitHub
parent bc6f7bdda9
commit 6b0203c8c4
6 changed files with 210 additions and 81 deletions
@@ -106,6 +106,19 @@ pub trait VoteTally<Votes, Class> {
fn rejection(class: Class) -> Self;
#[cfg(feature = "runtime-benchmarks")]
fn from_requirements(support: Perbill, approval: Perbill, class: Class) -> Self;
#[cfg(feature = "runtime-benchmarks")]
/// A function that should be called before any use of the `runtime-benchmarks` gated functions
/// of the `VoteTally` trait.
///
/// Should be used to set up any needed state in a Pallet which implements `VoteTally` so that
/// benchmarks that execute will complete successfully. `class` can be used to set up a
/// particular class of voters, and `granularity` is used to determine the weight of one vote
/// relative to total unanimity.
///
/// For example, in the case where there are a number of unique voters, and each voter has equal
/// voting weight, a granularity of `Perbill::from_rational(1, 1000)` should create `1_000`
/// users.
fn setup(class: Class, granularity: Perbill);
}
pub enum PollStatus<Tally, Moment, Class> {
None,