Browse Source

fixed reward account update Option<T> thing & updated tests

ignazio-bovo 3 years ago
parent
commit
3d368db49b

+ 3 - 3
runtime-modules/content/src/lib.rs

@@ -235,7 +235,7 @@ pub struct ChannelUpdateParametersRecord<StorageAssets, AccountId, DataObjectId:
     /// If set, metadata update for the channel.
     new_meta: Option<Vec<u8>>,
     /// If set, updates the reward account of the channel
-    reward_account: Option<AccountId>,
+    reward_account: Option<Option<AccountId>>,
     /// assets to be removed from channel
     assets_to_remove: BTreeSet<DataObjectId>,
     /// collaborator set
@@ -723,9 +723,9 @@ decl_module! {
             let mut channel = channel;
 
             // maybe update the reward account if actor is not a collaborator
-            if params.reward_account.is_some() {
+            if let Some(reward_account) = params.reward_account.as_ref() {
                 ensure_actor_not_a_collaborator::<T>(&actor)?;
-                channel.reward_account = params.reward_account.clone();
+                channel.reward_account = reward_account.clone();
             }
 
             // update collaborator set if actor is not a collaborator

+ 1 - 1
runtime-modules/content/src/tests/channels.rs

@@ -582,7 +582,7 @@ fn non_authorized_collaborators_cannot_update_channel() {
             ChannelUpdateParametersRecord {
                 assets_to_upload: None,
                 new_meta: None,
-                reward_account: Some(COLLABORATOR_MEMBER_ORIGIN),
+                reward_account: Some(Some(COLLABORATOR_MEMBER_ORIGIN)),
                 assets_to_remove: BTreeSet::new(),
                 collaborators: None,
             },

+ 3 - 4
runtime-modules/content/src/tests/mock.rs

@@ -505,10 +505,9 @@ pub fn update_channel_mock(
                 ChannelRecord {
                     owner: channel_pre.owner.clone(),
                     is_censored: channel_pre.is_censored,
-                    reward_account: params.reward_account.map_or_else(
-                        || channel_pre.reward_account.clone(),
-                        |account| Some(account)
-                    ),
+                    reward_account: params
+                        .reward_account
+                        .map_or_else(|| channel_pre.reward_account.clone(), |account| account),
                     deletion_prize_source_account_id: channel_pre.deletion_prize_source_account_id,
                     collaborators: params
                         .collaborators