mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 02:21:04 +00:00
Add field names to pallet Event variants (#9993)
* convert pallet-assets events to struct types * updated events of a couple pallets * updated pallet event field names * update pallet event field names * updated events in test files * cargo fmt * minorfixes * fix assertion error * minor fix * formatting fix * fmt
This commit is contained in:
@@ -128,7 +128,7 @@ benchmarks_instance_pallet! {
|
||||
let proposal_hash = T::Hashing::hash_of(&proposal);
|
||||
// Note that execution fails due to mis-matched origin
|
||||
assert_last_event::<T, I>(
|
||||
Event::MemberExecuted(proposal_hash, Err(DispatchError::BadOrigin)).into()
|
||||
Event::MemberExecuted { proposal_hash, result: Err(DispatchError::BadOrigin) }.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ benchmarks_instance_pallet! {
|
||||
let proposal_hash = T::Hashing::hash_of(&proposal);
|
||||
// Note that execution fails due to mis-matched origin
|
||||
assert_last_event::<T, I>(
|
||||
Event::Executed(proposal_hash, Err(DispatchError::BadOrigin)).into()
|
||||
Event::Executed { proposal_hash, result: Err(DispatchError::BadOrigin) }.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ benchmarks_instance_pallet! {
|
||||
// New proposal is recorded
|
||||
assert_eq!(Collective::<T, I>::proposals().len(), p as usize);
|
||||
let proposal_hash = T::Hashing::hash_of(&proposal);
|
||||
assert_last_event::<T, I>(Event::Proposed(caller, p - 1, proposal_hash, threshold).into());
|
||||
assert_last_event::<T, I>(Event::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold }.into());
|
||||
}
|
||||
|
||||
vote {
|
||||
@@ -359,7 +359,7 @@ benchmarks_instance_pallet! {
|
||||
verify {
|
||||
// The last proposal is removed.
|
||||
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
|
||||
assert_last_event::<T, I>(Event::Disapproved(last_hash).into());
|
||||
assert_last_event::<T, I>(Event::Disapproved { proposal_hash: last_hash }.into());
|
||||
}
|
||||
|
||||
close_early_approved {
|
||||
@@ -440,7 +440,7 @@ benchmarks_instance_pallet! {
|
||||
verify {
|
||||
// The last proposal is removed.
|
||||
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
|
||||
assert_last_event::<T, I>(Event::Executed(last_hash, Err(DispatchError::BadOrigin)).into());
|
||||
assert_last_event::<T, I>(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into());
|
||||
}
|
||||
|
||||
close_disapproved {
|
||||
@@ -514,7 +514,7 @@ benchmarks_instance_pallet! {
|
||||
}: close(SystemOrigin::Signed(caller), last_hash, index, Weight::max_value(), bytes_in_storage)
|
||||
verify {
|
||||
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
|
||||
assert_last_event::<T, I>(Event::Disapproved(last_hash).into());
|
||||
assert_last_event::<T, I>(Event::Disapproved { proposal_hash: last_hash }.into());
|
||||
}
|
||||
|
||||
close_approved {
|
||||
@@ -586,7 +586,7 @@ benchmarks_instance_pallet! {
|
||||
}: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::max_value(), bytes_in_storage)
|
||||
verify {
|
||||
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
|
||||
assert_last_event::<T, I>(Event::Executed(last_hash, Err(DispatchError::BadOrigin)).into());
|
||||
assert_last_event::<T, I>(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into());
|
||||
}
|
||||
|
||||
disapprove_proposal {
|
||||
@@ -634,7 +634,7 @@ benchmarks_instance_pallet! {
|
||||
}: _(SystemOrigin::Root, last_hash)
|
||||
verify {
|
||||
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
|
||||
assert_last_event::<T, I>(Event::Disapproved(last_hash).into());
|
||||
assert_last_event::<T, I>(Event::Disapproved { proposal_hash: last_hash }.into());
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Collective, crate::tests::new_test_ext(), crate::tests::Test);
|
||||
|
||||
@@ -279,27 +279,31 @@ pub mod pallet {
|
||||
pub enum Event<T: Config<I>, I: 'static = ()> {
|
||||
/// A motion (given hash) has been proposed (by given account) with a threshold (given
|
||||
/// `MemberCount`).
|
||||
/// \[account, proposal_index, proposal_hash, threshold\]
|
||||
Proposed(T::AccountId, ProposalIndex, T::Hash, MemberCount),
|
||||
Proposed {
|
||||
account: T::AccountId,
|
||||
proposal_index: ProposalIndex,
|
||||
proposal_hash: T::Hash,
|
||||
threshold: MemberCount,
|
||||
},
|
||||
/// A motion (given hash) has been voted on by given account, leaving
|
||||
/// a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
/// \[account, proposal_hash, voted, yes, no\]
|
||||
Voted(T::AccountId, T::Hash, bool, MemberCount, MemberCount),
|
||||
Voted {
|
||||
account: T::AccountId,
|
||||
proposal_hash: T::Hash,
|
||||
voted: bool,
|
||||
yes: MemberCount,
|
||||
no: MemberCount,
|
||||
},
|
||||
/// A motion was approved by the required threshold.
|
||||
/// \[proposal_hash\]
|
||||
Approved(T::Hash),
|
||||
Approved { proposal_hash: T::Hash },
|
||||
/// A motion was not approved by the required threshold.
|
||||
/// \[proposal_hash\]
|
||||
Disapproved(T::Hash),
|
||||
Disapproved { proposal_hash: T::Hash },
|
||||
/// A motion was executed; result will be `Ok` if it returned without error.
|
||||
/// \[proposal_hash, result\]
|
||||
Executed(T::Hash, DispatchResult),
|
||||
Executed { proposal_hash: T::Hash, result: DispatchResult },
|
||||
/// A single member did some action; result will be `Ok` if it returned without error.
|
||||
/// \[proposal_hash, result\]
|
||||
MemberExecuted(T::Hash, DispatchResult),
|
||||
MemberExecuted { proposal_hash: T::Hash, result: DispatchResult },
|
||||
/// A proposal was closed because its threshold was reached or after its duration was up.
|
||||
/// \[proposal_hash, yes, no\]
|
||||
Closed(T::Hash, MemberCount, MemberCount),
|
||||
Closed { proposal_hash: T::Hash, yes: MemberCount, no: MemberCount },
|
||||
}
|
||||
|
||||
/// Old name generated by `decl_event`.
|
||||
@@ -442,10 +446,10 @@ pub mod pallet {
|
||||
|
||||
let proposal_hash = T::Hashing::hash_of(&proposal);
|
||||
let result = proposal.dispatch(RawOrigin::Member(who).into());
|
||||
Self::deposit_event(Event::MemberExecuted(
|
||||
Self::deposit_event(Event::MemberExecuted {
|
||||
proposal_hash,
|
||||
result.map(|_| ()).map_err(|e| e.error),
|
||||
));
|
||||
result: result.map(|_| ()).map_err(|e| e.error),
|
||||
});
|
||||
|
||||
Ok(get_result_weight(result)
|
||||
.map(|w| {
|
||||
@@ -521,10 +525,10 @@ pub mod pallet {
|
||||
if threshold < 2 {
|
||||
let seats = Self::members().len() as MemberCount;
|
||||
let result = proposal.dispatch(RawOrigin::Members(1, seats).into());
|
||||
Self::deposit_event(Event::Executed(
|
||||
Self::deposit_event(Event::Executed {
|
||||
proposal_hash,
|
||||
result.map(|_| ()).map_err(|e| e.error),
|
||||
));
|
||||
result: result.map(|_| ()).map_err(|e| e.error),
|
||||
});
|
||||
|
||||
Ok(get_result_weight(result)
|
||||
.map(|w| {
|
||||
@@ -552,7 +556,12 @@ pub mod pallet {
|
||||
};
|
||||
<Voting<T, I>>::insert(proposal_hash, votes);
|
||||
|
||||
Self::deposit_event(Event::Proposed(who, index, proposal_hash, threshold));
|
||||
Self::deposit_event(Event::Proposed {
|
||||
account: who,
|
||||
proposal_index: index,
|
||||
proposal_hash,
|
||||
threshold,
|
||||
});
|
||||
|
||||
Ok(Some(T::WeightInfo::propose_proposed(
|
||||
proposal_len as u32, // B
|
||||
@@ -620,7 +629,13 @@ pub mod pallet {
|
||||
|
||||
let yes_votes = voting.ayes.len() as MemberCount;
|
||||
let no_votes = voting.nays.len() as MemberCount;
|
||||
Self::deposit_event(Event::Voted(who, proposal, approve, yes_votes, no_votes));
|
||||
Self::deposit_event(Event::Voted {
|
||||
account: who,
|
||||
proposal_hash: proposal,
|
||||
voted: approve,
|
||||
yes: yes_votes,
|
||||
no: no_votes,
|
||||
});
|
||||
|
||||
Voting::<T, I>::insert(&proposal, voting);
|
||||
|
||||
@@ -701,7 +716,7 @@ pub mod pallet {
|
||||
length_bound,
|
||||
proposal_weight_bound,
|
||||
)?;
|
||||
Self::deposit_event(Event::Closed(proposal_hash, yes_votes, no_votes));
|
||||
Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes });
|
||||
let (proposal_weight, proposal_count) =
|
||||
Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal);
|
||||
return Ok((
|
||||
@@ -713,7 +728,7 @@ pub mod pallet {
|
||||
)
|
||||
.into())
|
||||
} else if disapproved {
|
||||
Self::deposit_event(Event::Closed(proposal_hash, yes_votes, no_votes));
|
||||
Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes });
|
||||
let proposal_count = Self::do_disapprove_proposal(proposal_hash);
|
||||
return Ok((
|
||||
Some(T::WeightInfo::close_early_disapproved(seats, proposal_count)),
|
||||
@@ -746,7 +761,7 @@ pub mod pallet {
|
||||
length_bound,
|
||||
proposal_weight_bound,
|
||||
)?;
|
||||
Self::deposit_event(Event::Closed(proposal_hash, yes_votes, no_votes));
|
||||
Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes });
|
||||
let (proposal_weight, proposal_count) =
|
||||
Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal);
|
||||
Ok((
|
||||
@@ -758,7 +773,7 @@ pub mod pallet {
|
||||
)
|
||||
.into())
|
||||
} else {
|
||||
Self::deposit_event(Event::Closed(proposal_hash, yes_votes, no_votes));
|
||||
Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes });
|
||||
let proposal_count = Self::do_disapprove_proposal(proposal_hash);
|
||||
Ok((Some(T::WeightInfo::close_disapproved(seats, proposal_count)), Pays::No).into())
|
||||
}
|
||||
@@ -848,15 +863,15 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
proposal_hash: T::Hash,
|
||||
proposal: <T as Config<I>>::Proposal,
|
||||
) -> (Weight, u32) {
|
||||
Self::deposit_event(Event::Approved(proposal_hash));
|
||||
Self::deposit_event(Event::Approved { proposal_hash });
|
||||
|
||||
let dispatch_weight = proposal.get_dispatch_info().weight;
|
||||
let origin = RawOrigin::Members(yes_votes, seats).into();
|
||||
let result = proposal.dispatch(origin);
|
||||
Self::deposit_event(Event::Executed(
|
||||
Self::deposit_event(Event::Executed {
|
||||
proposal_hash,
|
||||
result.map(|_| ()).map_err(|e| e.error),
|
||||
));
|
||||
result: result.map(|_| ()).map_err(|e| e.error),
|
||||
});
|
||||
// default to the dispatch info weight for safety
|
||||
let proposal_weight = get_result_weight(result).unwrap_or(dispatch_weight); // P1
|
||||
|
||||
@@ -866,7 +881,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
|
||||
fn do_disapprove_proposal(proposal_hash: T::Hash) -> u32 {
|
||||
// disapproved
|
||||
Self::deposit_event(Event::Disapproved(proposal_hash));
|
||||
Self::deposit_event(Event::Disapproved { proposal_hash });
|
||||
Self::remove_proposal(proposal_hash)
|
||||
}
|
||||
|
||||
|
||||
@@ -216,11 +216,32 @@ fn close_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash }))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -315,11 +336,32 @@ fn close_with_prime_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash }))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -354,15 +396,36 @@ fn close_with_voting_prime_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 3, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
}))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -404,16 +467,45 @@ fn close_with_no_prime_but_majority_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Proposed(1, 0, hash, 5))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted(3, hash, true, 3, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Closed(hash, 5, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Approved(hash))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
)))
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 5
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted {
|
||||
account: 3,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 5,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Approved {
|
||||
proposal_hash: hash
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
}))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -537,7 +629,12 @@ fn propose_works() {
|
||||
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3)))]
|
||||
vec![record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
}))]
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -696,9 +793,26 @@ fn motions_vote_after_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, false, 0, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: false,
|
||||
yes: 0,
|
||||
no: 1
|
||||
})),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -812,15 +926,36 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
})),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -840,14 +975,44 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 1, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(3, hash, true, 3, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 3, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 1,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 3,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Democracy(mock_democracy::pallet::Event::<Test>::ExternalProposed)),
|
||||
record(Event::Collective(CollectiveEvent::Executed(hash, Ok(())))),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Ok(())
|
||||
})),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -873,11 +1038,32 @@ fn motions_disapproval_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, false, 1, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 1, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: false,
|
||||
yes: 1,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 1,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -903,15 +1089,36 @@ fn motions_approval_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
})),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -932,7 +1139,12 @@ fn motion_with_no_votes_closes_with_disapproval() {
|
||||
));
|
||||
assert_eq!(
|
||||
System::events()[0],
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
}))
|
||||
);
|
||||
|
||||
// Closing the motion too early is not possible because it has neither
|
||||
@@ -951,11 +1163,15 @@ fn motion_with_no_votes_closes_with_disapproval() {
|
||||
// Events show that the close ended in a disapproval.
|
||||
assert_eq!(
|
||||
System::events()[1],
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 0, 3)))
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 0,
|
||||
no: 3
|
||||
}))
|
||||
);
|
||||
assert_eq!(
|
||||
System::events()[2],
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash)))
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash }))
|
||||
);
|
||||
})
|
||||
}
|
||||
@@ -1015,10 +1231,27 @@ fn disapprove_proposal_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })),
|
||||
]
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user