|
@@ -231,27 +231,6 @@ impl VetoProposalFixture {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct EmergencyProposalCancellationFixture {
|
|
|
- origin: RawOrigin<u64>,
|
|
|
- proposal_id: u32,
|
|
|
-}
|
|
|
-
|
|
|
-impl EmergencyProposalCancellationFixture {
|
|
|
- fn new(proposal_id: u32) -> Self {
|
|
|
- EmergencyProposalCancellationFixture {
|
|
|
- proposal_id,
|
|
|
- origin: RawOrigin::Root,
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- fn cancel_and_assert(self, expected_result: DispatchResult) {
|
|
|
- assert_eq!(
|
|
|
- ProposalsEngine::emergency_proposal_cancellation(self.origin.into(), self.proposal_id,),
|
|
|
- expected_result
|
|
|
- );
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
struct VoteGenerator {
|
|
|
proposal_id: u32,
|
|
|
current_account_id: u64,
|
|
@@ -737,7 +716,7 @@ fn cancel_proposal_fails_with_insufficient_rights() {
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
-fn veto_proposal_succeeds() {
|
|
|
+fn veto_proposal_succeeds_during_voting_period() {
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let starting_block = 1;
|
|
|
run_to_block_and_finalize(starting_block);
|
|
@@ -753,6 +732,11 @@ fn veto_proposal_succeeds() {
|
|
|
// internal active proposal counter check
|
|
|
assert_eq!(<ActiveProposalCount>::get(), 1);
|
|
|
|
|
|
+ assert!(matches!(
|
|
|
+ <Proposals<Test>>::get(proposal_id).status,
|
|
|
+ ProposalStatus::Active{..}
|
|
|
+ ));
|
|
|
+
|
|
|
let veto_proposal = VetoProposalFixture::new(proposal_id);
|
|
|
veto_proposal.veto_and_assert(Ok(()));
|
|
|
|
|
@@ -768,26 +752,7 @@ fn veto_proposal_succeeds() {
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
-fn veto_proposal_fails_with_not_existing_proposal() {
|
|
|
- initial_test_ext().execute_with(|| {
|
|
|
- let veto_proposal = VetoProposalFixture::new(2);
|
|
|
- veto_proposal.veto_and_assert(Err(Error::<Test>::ProposalNotFound.into()));
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-#[test]
|
|
|
-fn veto_proposal_fails_with_insufficient_rights() {
|
|
|
- initial_test_ext().execute_with(|| {
|
|
|
- let dummy_proposal = DummyProposalFixture::default();
|
|
|
- let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
|
|
|
-
|
|
|
- let veto_proposal = VetoProposalFixture::new(proposal_id).with_origin(RawOrigin::Signed(2));
|
|
|
- veto_proposal.veto_and_assert(Err(DispatchError::BadOrigin));
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-#[test]
|
|
|
-fn emergency_proposal_cancellation_succeeds() {
|
|
|
+fn veto_proposal_succeeds_during_grace_period() {
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let starting_block = 1;
|
|
|
run_to_block_and_finalize(starting_block);
|
|
@@ -811,12 +776,17 @@ fn emergency_proposal_cancellation_succeeds() {
|
|
|
|
|
|
run_to_block_and_finalize(6);
|
|
|
|
|
|
- let cancel_proposal = EmergencyProposalCancellationFixture::new(proposal_id);
|
|
|
- cancel_proposal.cancel_and_assert(Ok(()));
|
|
|
+ assert!(matches!(
|
|
|
+ <Proposals<Test>>::get(proposal_id).status,
|
|
|
+ ProposalStatus::PendingExecution{..}
|
|
|
+ ));
|
|
|
+
|
|
|
+ let veto_proposal = VetoProposalFixture::new(proposal_id);
|
|
|
+ veto_proposal.veto_and_assert(Ok(()));
|
|
|
|
|
|
EventFixture::assert_last_crate_event(RawEvent::ProposalDecisionMade(
|
|
|
proposal_id,
|
|
|
- ProposalDecision::Canceled,
|
|
|
+ ProposalDecision::Vetoed,
|
|
|
));
|
|
|
|
|
|
assert!(!<crate::Proposals<Test>>::contains_key(proposal_id));
|
|
@@ -826,15 +796,7 @@ fn emergency_proposal_cancellation_succeeds() {
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
-fn emergency_proposal_cancellation_fails_with_not_existing_proposal() {
|
|
|
- initial_test_ext().execute_with(|| {
|
|
|
- let emergency_proposal = EmergencyProposalCancellationFixture::new(2);
|
|
|
- emergency_proposal.cancel_and_assert(Err(Error::<Test>::ProposalNotFound.into()));
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-#[test]
|
|
|
-fn emergency_proposal_cancellation_fails_before_grace_period() {
|
|
|
+fn veto_proposal_succeeds_during_pending_constitutionality() {
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let starting_block = 1;
|
|
|
run_to_block_and_finalize(starting_block);
|
|
@@ -842,7 +804,7 @@ fn emergency_proposal_cancellation_fails_before_grace_period() {
|
|
|
// internal active proposal counter check
|
|
|
assert_eq!(<ActiveProposalCount>::get(), 0);
|
|
|
|
|
|
- let parameters_fixture = ProposalParametersFixture::default();
|
|
|
+ let parameters_fixture = ProposalParametersFixture::default().with_constitutionality(10);
|
|
|
let dummy_proposal =
|
|
|
DummyProposalFixture::default().with_parameters(parameters_fixture.params());
|
|
|
let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
|
|
@@ -850,17 +812,42 @@ fn emergency_proposal_cancellation_fails_before_grace_period() {
|
|
|
// internal active proposal counter check
|
|
|
assert_eq!(<ActiveProposalCount>::get(), 1);
|
|
|
|
|
|
- let cancel_proposal = EmergencyProposalCancellationFixture::new(proposal_id);
|
|
|
- cancel_proposal.cancel_and_assert(Err(Error::<Test>::ProposalNotPendingExecution.into()));
|
|
|
+ let mut vote_generator = VoteGenerator::new(proposal_id);
|
|
|
+ vote_generator.vote_and_assert_ok(VoteKind::Approve);
|
|
|
+ vote_generator.vote_and_assert_ok(VoteKind::Approve);
|
|
|
+ vote_generator.vote_and_assert_ok(VoteKind::Approve);
|
|
|
|
|
|
- assert!(<crate::Proposals<Test>>::contains_key(proposal_id));
|
|
|
+ run_to_block_and_finalize(6);
|
|
|
+
|
|
|
+ assert!(matches!(
|
|
|
+ <Proposals<Test>>::get(proposal_id).status,
|
|
|
+ ProposalStatus::PendingConstitutionality{..}
|
|
|
+ ));
|
|
|
+
|
|
|
+ let veto_proposal = VetoProposalFixture::new(proposal_id);
|
|
|
+ veto_proposal.veto_and_assert(Ok(()));
|
|
|
+
|
|
|
+ EventFixture::assert_last_crate_event(RawEvent::ProposalDecisionMade(
|
|
|
+ proposal_id,
|
|
|
+ ProposalDecision::Vetoed,
|
|
|
+ ));
|
|
|
+
|
|
|
+ assert!(!<crate::Proposals<Test>>::contains_key(proposal_id));
|
|
|
// internal active proposal counter check
|
|
|
- assert_eq!(<ActiveProposalCount>::get(), 1);
|
|
|
+ assert_eq!(<ActiveProposalCount>::get(), 0);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
-fn emergency_proposal_fails_with_insufficient_rights() {
|
|
|
+fn veto_proposal_fails_with_not_existing_proposal() {
|
|
|
+ initial_test_ext().execute_with(|| {
|
|
|
+ let veto_proposal = VetoProposalFixture::new(2);
|
|
|
+ veto_proposal.veto_and_assert(Err(Error::<Test>::ProposalNotFound.into()));
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+#[test]
|
|
|
+fn veto_proposal_fails_with_insufficient_rights() {
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let dummy_proposal = DummyProposalFixture::default();
|
|
|
let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
|