Browse Source

Add tests for engine errors

Shamil Gadelshin 5 years ago
parent
commit
2ebff4ae73
1 changed files with 27 additions and 0 deletions
  1. 27 0
      runtime-modules/proposals/engine/src/tests/mod.rs

+ 27 - 0
runtime-modules/proposals/engine/src/tests/mod.rs

@@ -1299,3 +1299,30 @@ fn finalize_proposal_using_stake_mocks_failed() {
         });
     });
 }
+
+#[test]
+fn create_proposal_fails_with_invalid_threshold_parameters() {
+    initial_test_ext().execute_with(|| {
+        let mut parameters = ProposalParameters {
+            voting_period: 3,
+            approval_quorum_percentage: 50,
+            approval_threshold_percentage: 0,
+            slashing_quorum_percentage: 60,
+            slashing_threshold_percentage: 60,
+            grace_period: 5,
+            required_stake: None,
+        };
+
+        let mut dummy_proposal = DummyProposalFixture::default().with_parameters(parameters);
+
+        dummy_proposal
+            .create_proposal_and_assert(Err(Error::InvalidParameterApprovalThreshold.into()));
+
+        parameters.approval_threshold_percentage = 60;
+        parameters.slashing_threshold_percentage = 0;
+        dummy_proposal = DummyProposalFixture::default().with_parameters(parameters);
+
+        dummy_proposal
+            .create_proposal_and_assert(Err(Error::InvalidParameterSlashingThreshold.into()));
+    });
+}