Skip to content
Closed
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
8 changes: 4 additions & 4 deletions pallets/collective/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ benchmarks_instance_pallet! {
// Whitelist voter account from further DB operations.
let voter_key = frame_system::Account::<T>::hashed_key_for(&voter);
frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into());
}: close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage)
}: close(<frame_system::RawOrigin<AccountId> as Into<T>>::into(SystemOrigin::Root), last_hash, index, Weight::MAX, bytes_in_storage)
verify {
// The last proposal is removed.
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
Expand Down Expand Up @@ -393,7 +393,7 @@ benchmarks_instance_pallet! {
index, approve,
)?;

}: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage)
}: close(<frame_system::RawOrigin<AccountId> as Into<T>>::into(SystemOrigin::Root), last_hash, index, Weight::MAX, bytes_in_storage)
verify {
// The last proposal is removed.
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
Expand Down Expand Up @@ -473,7 +473,7 @@ benchmarks_instance_pallet! {
assert_eq!(Collective::<T, I>::proposals().len(), p as usize);

// Prime nay will close it as disapproved
}: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage)
}: close(<frame_system::RawOrigin<AccountId> as Into<T>>::into(SystemOrigin::Root), last_hash, index, Weight::MAX, bytes_in_storage)
verify {
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
assert_last_event::<T, I>(Event::Disapproved { proposal_hash: last_hash }.into());
Expand Down Expand Up @@ -542,7 +542,7 @@ benchmarks_instance_pallet! {
assert_eq!(Collective::<T, I>::proposals().len(), p as usize);

// Prime aye will close it as approved
}: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::MAX, bytes_in_storage)
}: close(<frame_system::RawOrigin<AccountId> as Into<T>>::into(SystemOrigin::Root), last_hash, p - 1, Weight::MAX, bytes_in_storage)
verify {
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
assert_last_event::<T, I>(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into());
Expand Down
46 changes: 20 additions & 26 deletions pallets/collective/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn close_works() {
System::set_block_number(3);
assert_noop!(
Collective::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand All @@ -310,7 +310,7 @@ fn close_works() {

System::set_block_number(4);
assert_ok!(Collective::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -370,7 +370,7 @@ fn proposal_weight_limit_works_on_approve() {
System::set_block_number(4);
assert_noop!(
Collective::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight - Weight::from_parts(100, 0),
Expand All @@ -379,7 +379,7 @@ fn proposal_weight_limit_works_on_approve() {
Error::<Test, Instance1>::ProposalWeightLessThanDispatchCallWeight
);
assert_ok!(Collective::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -409,7 +409,7 @@ fn proposal_weight_limit_ignored_on_disapprove() {
// No votes, this proposal wont pass
System::set_block_number(4);
assert_ok!(Collective::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight - Weight::from_parts(100, 0),
Expand Down Expand Up @@ -442,7 +442,7 @@ fn close_with_prime_works() {

System::set_block_number(4);
assert_ok!(Collective::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -502,7 +502,7 @@ fn close_with_voting_prime_works() {

System::set_block_number(4);
assert_ok!(Collective::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -583,7 +583,7 @@ fn close_with_no_prime_but_majority_works() {

System::set_block_number(4);
assert_ok!(CollectiveMajority::close(
RuntimeOrigin::signed(4),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -1109,7 +1109,7 @@ fn motions_all_first_vote_free_works() {

let proposal_weight = proposal.get_dispatch_info().weight;
let close_rval: DispatchResultWithPostInfo = Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand All @@ -1120,7 +1120,7 @@ fn motions_all_first_vote_free_works() {
// Trying to close the proposal, which is already closed
// Error: "ProposalNotExists" with Pays::Yes.
let close_rval: DispatchResultWithPostInfo = Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -1148,7 +1148,7 @@ fn motions_reproposing_disapproved_works() {
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false));

assert_ok!(Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -1186,7 +1186,7 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true));
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true));
assert_ok!(Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -1243,7 +1243,7 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 1, true));
assert_ok!(Collective::vote(RuntimeOrigin::signed(3), hash, 1, true));
assert_ok!(Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
1,
proposal_weight,
Expand Down Expand Up @@ -1315,7 +1315,7 @@ fn motions_disapproval_works() {
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, false));
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false));
assert_ok!(Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -1374,7 +1374,7 @@ fn motions_approval_works() {
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true));
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true));
assert_ok!(Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -1448,7 +1448,7 @@ fn motion_with_no_votes_closes_with_disapproval() {
// an approving or disapproving simple majority due to the lack of votes.
assert_noop!(
Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand All @@ -1462,7 +1462,7 @@ fn motion_with_no_votes_closes_with_disapproval() {
System::set_block_number(closing_block);
// we can successfully close the motion.
assert_ok!(Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
proposal_weight,
Expand Down Expand Up @@ -1507,25 +1507,19 @@ fn close_disapprove_does_not_care_about_weight_or_len() {
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true));
// It will not close with bad weight/len information
assert_noop!(
Collective::close(RuntimeOrigin::signed(2), hash, 0, Weight::zero(), 0),
Collective::close(RuntimeOrigin::root(), hash, 0, Weight::zero(), 0),
Error::<Test, Instance1>::ProposalLengthBoundLessThanProposalLength,
);
assert_noop!(
Collective::close(
RuntimeOrigin::signed(2),
hash,
0,
Weight::zero(),
proposal_len
),
Collective::close(RuntimeOrigin::root(), hash, 0, Weight::zero(), proposal_len),
Error::<Test, Instance1>::ProposalWeightLessThanDispatchCallWeight,
);
// Now we make the proposal fail
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, false));
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false));
// It can close even if the weight/len information is bad
assert_ok!(Collective::close(
RuntimeOrigin::signed(2),
RuntimeOrigin::root(),
hash,
0,
Weight::zero(),
Expand Down