Browse Source

Merge pull request #3361 from Lezek123/olympia-bounty-issue

Bounty: Allow slashing entrant with no works submitted
shamil-gadelshin 3 years ago
parent
commit
73f4b028df
2 changed files with 8 additions and 16 deletions
  1. 7 7
      runtime-modules/bounty/src/lib.rs
  2. 1 9
      runtime-modules/bounty/src/tests/mod.rs

+ 7 - 7
runtime-modules/bounty/src/lib.rs

@@ -1613,19 +1613,19 @@ impl<T: Trait> Module<T> {
 
         // Validate all work entry judgements.
         for (entry_id, work_entry_judgment) in judgment.iter() {
+            let entry = Self::ensure_work_entry_exists(bounty_id, entry_id)?;
             if let OracleWorkEntryJudgment::Winner { reward } = work_entry_judgment {
                 // Check for zero reward.
                 ensure!(*reward != Zero::zero(), Error::<T>::ZeroWinnerReward);
 
+                // Check winner work submission.
+                ensure!(
+                    entry.work_submitted,
+                    Error::<T>::WinnerShouldHasWorkSubmission
+                );
+
                 reward_sum_from_judgment += *reward;
             }
-
-            // Check winner work submission.
-            let entry = Self::ensure_work_entry_exists(bounty_id, entry_id)?;
-            ensure!(
-                entry.work_submitted,
-                Error::<T>::WinnerShouldHasWorkSubmission
-            );
         }
 
         // Check for invalid total sum for successful bounty.

+ 1 - 9
runtime-modules/bounty/src/tests/mod.rs

@@ -2518,7 +2518,7 @@ fn submit_judgment_by_council_succeeded_with_complex_judgment() {
             .with_work_data(work_data.clone())
             .call_and_assert(Ok(()));
 
-        // Third work entry
+        // Third work entry (no works submitted)
         let member_id = 3;
         let account_id = 3;
 
@@ -2533,14 +2533,6 @@ fn submit_judgment_by_council_succeeded_with_complex_judgment() {
 
         let entry_id3 = 3u64;
 
-        let work_data = b"Work submitted".to_vec();
-        SubmitWorkFixture::default()
-            .with_origin(RawOrigin::Signed(account_id))
-            .with_member_id(member_id)
-            .with_entry_id(entry_id3)
-            .with_work_data(work_data.clone())
-            .call_and_assert(Ok(()));
-
         run_to_block(starting_block + working_period + 1);
 
         // Judgment