Browse Source

council - event tests

ondratra 4 years ago
parent
commit
9e8d03ba44
1 changed files with 31 additions and 2 deletions
  1. 31 2
      runtime-modules/council/src/mock.rs

+ 31 - 2
runtime-modules/council/src/mock.rs

@@ -4,8 +4,8 @@
 use crate::{
 use crate::{
     AnnouncementPeriodNr, Balance, Budget, CandidateOf, Candidates, CouncilMemberOf,
     AnnouncementPeriodNr, Balance, Budget, CandidateOf, Candidates, CouncilMemberOf,
     CouncilMembers, CouncilStage, CouncilStageAnnouncing, CouncilStageElection, CouncilStageUpdate,
     CouncilMembers, CouncilStage, CouncilStageAnnouncing, CouncilStageElection, CouncilStageUpdate,
-    CouncilStageUpdateOf, Error, GenesisConfig, Module, NextBudgetRefill, ReferendumConnection,
-    Stage, Trait,
+    CouncilStageUpdateOf, Error, GenesisConfig, Module, NextBudgetRefill, RawEvent,
+    ReferendumConnection, Stage, Trait,
 };
 };
 
 
 use balances;
 use balances;
@@ -669,6 +669,13 @@ where
         if expected_result.is_err() {
         if expected_result.is_err() {
             return;
             return;
         }
         }
+        assert_eq!(
+            system::Module::<Runtime>::events().last().unwrap().event,
+            TestEvent::event_mod(RawEvent::CandidacyNoteSet(
+                membership_id.into().into(),
+                note.into()
+            )),
+        );
 
 
         Self::check_candidacy_note(&membership_id, Some(note));
         Self::check_candidacy_note(&membership_id, Some(note));
     }
     }
@@ -690,6 +697,18 @@ where
             ),
             ),
             expected_result,
             expected_result,
         );
         );
+
+        if expected_result.is_err() {
+            return;
+        }
+
+        assert_eq!(
+            system::Module::<Runtime>::events().last().unwrap().event,
+            TestEvent::event_mod(RawEvent::NewCandidate(
+                member_id.into().into(),
+                stake.into()
+            )),
+        );
     }
     }
 
 
     pub fn vote_for_candidate(
     pub fn vote_for_candidate(
@@ -759,6 +778,11 @@ where
         }
         }
 
 
         assert_eq!(Budget::<T>::get(), amount,);
         assert_eq!(Budget::<T>::get(), amount,);
+
+        assert_eq!(
+            system::Module::<Runtime>::events().last().unwrap().event,
+            TestEvent::event_mod(RawEvent::BudgetBalanceSet(amount.into())),
+        );
     }
     }
 
 
     pub fn plan_budget_refill(
     pub fn plan_budget_refill(
@@ -781,6 +805,11 @@ where
         }
         }
 
 
         assert_eq!(NextBudgetRefill::<T>::get(), next_refill,);
         assert_eq!(NextBudgetRefill::<T>::get(), next_refill,);
+
+        assert_eq!(
+            system::Module::<Runtime>::events().last().unwrap().event,
+            TestEvent::event_mod(RawEvent::BudgetRefillPlanned(next_refill.into())),
+        );
     }
     }
 
 
     /// simulate one council's election cycle
     /// simulate one council's election cycle