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

pallet-collective | port to frame v2 #8193

Closed
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5d949bb
wk2108 | port to frame v2 macro definition
shamb0 Feb 24, 2021
a2aa4ef
Update frame/collective/src/lib.rs
shamb0 Feb 24, 2021
c464d0d
Update frame/collective/src/lib.rs
shamb0 Feb 24, 2021
dece855
wk2108 | port to frame v2 | weight review comments fix
shamb0 Feb 24, 2021
1ea6867
pallet-collective frame v2 port merge to upstream master
shamb0 Mar 29, 2021
bcf3615
pallet-collective frame v2 port rumtime migration updates
shamb0 Mar 29, 2021
e35a1f1
pallet-collective frame v2 port fix review remarks on runtime upgrade
shamb0 Mar 30, 2021
5e1b90b
pallet-collective frame v2 port fix review remarks on runtime upgrade
shamb0 Mar 31, 2021
3dea53f
Merge remote-tracking branch 'upstream/master' into shamb0-br2-collec…
shamb0 Mar 31, 2021
0a334eb
pallet-collective port frame v2 runtime migration unit test update
shamb0 Apr 1, 2021
a57574a
Merge remote-tracking branch 'upstream/master' into shamb0-br2-collec…
shamb0 Apr 1, 2021
a859fb3
Merge remote-tracking branch 'upstream/master' into shamb0-br2-collec…
shamb0 Apr 4, 2021
3ffae36
review comment closure
shamb0 Apr 4, 2021
6f7991c
Update frame/system/src/lib.rs
gui1117 Apr 13, 2021
cdb809e
merge to upstream master updates
shamb0 Apr 15, 2021
5893139
Merge branch 'shamb0-br2-collective-port-frame-v2' of github.com:sham…
shamb0 Apr 15, 2021
b718f80
Update frame/collective/src/lib.rs
gui1117 Apr 15, 2021
545fb1d
Update frame/collective/src/lib.rs
gui1117 Apr 15, 2021
86d8a54
Update frame/collective/src/lib.rs
gui1117 Apr 15, 2021
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
24 changes: 12 additions & 12 deletions frame/collective/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::*;
use frame_system::RawOrigin as SystemOrigin;
use frame_system::EventRecord;
use frame_benchmarking::{
benchmarks_instance,
benchmarks_instance_pallet,
account,
whitelisted_caller,
impl_benchmark_test_suite,
Expand All @@ -32,21 +32,21 @@ use sp_std::mem::size_of;

use frame_system::Call as SystemCall;
use frame_system::Pallet as System;
use crate::Module as Collective;
use crate::Pallet as Collective;

const SEED: u32 = 0;

const MAX_BYTES: u32 = 1_024;

fn assert_last_event<T: Config<I>, I: Instance>(generic_event: <T as Config<I>>::Event) {
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::Event) {
let events = System::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into();
// compare to the last event record
let EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}

benchmarks_instance! {
benchmarks_instance_pallet! {
set_members {
let m in 1 .. T::MaxMembers::get();
let n in 1 .. T::MaxMembers::get();
Expand Down Expand Up @@ -138,7 +138,7 @@ benchmarks_instance! {
let proposal_hash = T::Hashing::hash_of(&proposal);
// Note that execution fails due to mis-matched origin
assert_last_event::<T, I>(
RawEvent::MemberExecuted(proposal_hash, Err(DispatchError::BadOrigin)).into()
Event::MemberExecuted(proposal_hash, Err(DispatchError::BadOrigin)).into()
);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ benchmarks_instance! {
let proposal_hash = T::Hashing::hash_of(&proposal);
// Note that execution fails due to mis-matched origin
assert_last_event::<T, I>(
RawEvent::Executed(proposal_hash, Err(DispatchError::BadOrigin)).into()
Event::Executed(proposal_hash, Err(DispatchError::BadOrigin)).into()
);
}

Expand Down Expand Up @@ -213,7 +213,7 @@ benchmarks_instance! {
// New proposal is recorded
assert_eq!(Collective::<T, _>::proposals().len(), p as usize);
let proposal_hash = T::Hashing::hash_of(&proposal);
assert_last_event::<T, I>(RawEvent::Proposed(caller, p - 1, proposal_hash, threshold).into());
assert_last_event::<T, I>(Event::Proposed(caller, p - 1, proposal_hash, threshold).into());
}

vote {
Expand Down Expand Up @@ -369,7 +369,7 @@ benchmarks_instance! {
verify {
// The last proposal is removed.
assert_eq!(Collective::<T, _>::proposals().len(), (p - 1) as usize);
assert_last_event::<T, I>(RawEvent::Disapproved(last_hash).into());
assert_last_event::<T, I>(Event::Disapproved(last_hash).into());
}

close_early_approved {
Expand Down Expand Up @@ -450,7 +450,7 @@ benchmarks_instance! {
verify {
// The last proposal is removed.
assert_eq!(Collective::<T, _>::proposals().len(), (p - 1) as usize);
assert_last_event::<T, I>(RawEvent::Executed(last_hash, Err(DispatchError::BadOrigin)).into());
assert_last_event::<T, I>(Event::Executed(last_hash, Err(DispatchError::BadOrigin)).into());
}

close_disapproved {
Expand Down Expand Up @@ -522,7 +522,7 @@ benchmarks_instance! {
}: close(SystemOrigin::Signed(caller), last_hash, index, Weight::max_value(), bytes_in_storage)
verify {
assert_eq!(Collective::<T, _>::proposals().len(), (p - 1) as usize);
assert_last_event::<T, I>(RawEvent::Disapproved(last_hash).into());
assert_last_event::<T, I>(Event::Disapproved(last_hash).into());
}

close_approved {
Expand Down Expand Up @@ -586,7 +586,7 @@ benchmarks_instance! {
}: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::max_value(), bytes_in_storage)
verify {
assert_eq!(Collective::<T, _>::proposals().len(), (p - 1) as usize);
assert_last_event::<T, I>(RawEvent::Executed(last_hash, Err(DispatchError::BadOrigin)).into());
assert_last_event::<T, I>(Event::Executed(last_hash, Err(DispatchError::BadOrigin)).into());
}

disapprove_proposal {
Expand Down Expand Up @@ -634,7 +634,7 @@ benchmarks_instance! {
}: _(SystemOrigin::Root, last_hash)
verify {
assert_eq!(Collective::<T, _>::proposals().len(), (p - 1) as usize);
assert_last_event::<T, I>(RawEvent::Disapproved(last_hash).into());
assert_last_event::<T, I>(Event::Disapproved(last_hash).into());
}
}

Expand Down
Loading