Browse Source

uns claim request twice

ignazio 3 years ago
parent
commit
2f4e91e0b3

+ 4 - 6
runtime-modules/content/src/tests/fixtures.rs

@@ -1321,19 +1321,17 @@ impl ClaimChannelRewardFixture {
 
         let actual_result =
             Content::claim_channel_reward(origin, self.actor.clone(), proof, self.item.clone());
+
         let balance_post = Balances::<Test>::usable_balance(self.sender);
         let payout_earned_post =
             Content::channel_by_id(self.item.channel_id).cumulative_payout_earned;
+
         assert_eq!(actual_result, expected_result);
 
         if actual_result.is_ok() {
-            assert_eq!(
-                balance_post.saturating_sub(balance_pre),
-                payout_earned_post.saturating_sub(payout_earned_pre)
-            );
-
+            let cashout = payout_earned_post.saturating_sub(payout_earned_pre);
+            assert_eq!(balance_post.saturating_sub(balance_pre), cashout);
             assert_eq!(payout_earned_post, self.item.cumulative_payout_claimed);
-
             assert_eq!(
                 System::events().last().unwrap().event,
                 MetaEvent::content(RawEvent::ChannelRewardUpdated(

+ 22 - 0
runtime-modules/content/src/tests/merkle.rs

@@ -327,3 +327,25 @@ fn unsuccessful_reward_claim_with_no_commitment_value_outstanding() {
             .call_and_assert(Err(Error::<Test>::PaymentProofVerificationFailed.into()))
     })
 }
+
+#[test]
+fn unsuccessful_reward_claim_with_successive_request() {
+    with_default_mock_builder(|| {
+        run_to_block(1);
+
+        create_initial_storage_buckets_helper();
+        increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
+        create_default_member_owned_channel_with_video();
+        let payments = create_some_pull_payments_helper();
+        update_commit_value_with_payments_helper(&payments);
+
+        ClaimChannelRewardFixture::default()
+            .with_payments(payments.clone())
+            .call_and_assert(Ok(()));
+
+        // cashout is 0 now
+        ClaimChannelRewardFixture::default()
+            .with_payments(payments)
+            .call_and_assert(Err(Error::<Test>::UnsufficientCashoutAmount.into()))
+    })
+}