Pārlūkot izejas kodu

runtime: Upgrade the content-working group pallet.

Shamil Gadelshin 4 gadi atpakaļ
vecāks
revīzija
04439934af

+ 25 - 0
Cargo.lock

@@ -1003,6 +1003,31 @@ dependencies = [
  "sp-runtime",
 ]
 
+[[package]]
+name = "pallet-content-working-group"
+version = "3.0.0"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "pallet-balances",
+ "pallet-common",
+ "pallet-hiring",
+ "pallet-membership",
+ "pallet-recurring-reward",
+ "pallet-stake",
+ "pallet-timestamp",
+ "pallet-token-mint",
+ "pallet-versioned-store",
+ "pallet-versioned-store-permissions",
+ "parity-scale-codec",
+ "serde",
+ "sp-arithmetic",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+]
+
 [[package]]
 name = "pallet-forum"
 version = "3.0.0"

+ 1 - 1
Cargo.toml

@@ -5,7 +5,7 @@ members = [
 #	"runtime-modules/proposals/codex",
 #	"runtime-modules/proposals/discussion",
 	"runtime-modules/common",
-#	"runtime-modules/content-working-group",
+	"runtime-modules/content-working-group",
 	"runtime-modules/forum",
 	"runtime-modules/governance",
 	"runtime-modules/hiring",

+ 37 - 120
runtime-modules/content-working-group/Cargo.toml

@@ -1,131 +1,48 @@
 [package]
-name = 'substrate-content-working-group-module'
-version = '1.1.0'
+name = 'pallet-content-working-group'
+version = '3.0.0'
 authors = ['Joystream contributors']
 edition = '2018'
 
+[dependencies]
+serde = { version = "1.0.101", optional = true, features = ["derive"] }
+codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
+rstd = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
+stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
+hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
+minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
+recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'}
+versioned_store = { package = 'pallet-versioned-store', default-features = false, path = '../versioned-store'}
+versioned_store_permissions = { package = 'pallet-versioned-store-permissions', default-features = false, path = '../versioned-store-permissions'}
+common = { package = 'pallet-common', default-features = false, path = '../common'}
+
+[dev-dependencies]
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+
 [features]
 default = ['std']
 std = [
-	'sr-primitives/std',
-	'srml-support/std',
+	'serde',
+	'codec/std',
+	'rstd/std',
+	'frame-support/std',
 	'system/std',
-    'serde',
-    'codec/std',
-    'primitives/std',
-    'rstd/std',
-    'membership/std',
-    'forum/std',
-    'hiring/std',
-    'stake/std',
-    'minting/std',
+	'sp-arithmetic/std',
+	'sp-runtime/std',
+	'membership/std',
+	'stake/std',
+	'hiring/std',
+	'minting/std',
+	'recurringrewards/std',
     'versioned_store/std',
     'versioned_store_permissions/std',
-    'recurringrewards/std',
-    'common/std',
+	'common/std',
 ]
-
-
-[dependencies.sr-primitives]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-primitives'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.srml-support]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-support'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.system]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-system'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.rstd]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-std'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.serde]
-features = ['derive']
-optional = true
-version = '1.0.101'
-
-[dependencies.primitives]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'substrate-primitives'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '1.0.0'
-
-[dependencies.forum]
-default_features = false
-package = 'substrate-forum-module'
-path = '../forum'
-
-[dependencies.minting]
-default_features = false
-package = 'substrate-token-mint-module'
-path = '../token-minting'
-
-[dependencies.stake]
-default_features = false
-package = 'substrate-stake-module'
-path = '../stake'
-
-[dependencies.recurringrewards]
-default_features = false
-package = 'substrate-recurring-reward-module'
-path = '../recurring-reward'
-
-[dependencies.hiring]
-default_features = false
-package = 'substrate-hiring-module'
-path = '../hiring'
-
-[dependencies.versioned_store]
-default_features = false
-package ='substrate-versioned-store'
-path = '../versioned-store'
-
-[dependencies.versioned_store_permissions]
-default_features = false
-package = 'substrate-versioned-store-permissions-module'
-path = '../versioned-store-permissions'
-
-[dependencies.membership]
-default_features = false
-package = 'substrate-membership-module'
-path = '../membership'
-
-[dependencies.common]
-default_features = false
-package = 'substrate-common-module'
-path = '../common'
-
-[dev-dependencies.runtime-io]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-io'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dev-dependencies.balances]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-balances'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dev-dependencies.timestamp]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-timestamp'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'

+ 2 - 60
runtime-modules/content-working-group/src/genesis.rs

@@ -1,36 +1,13 @@
 #![cfg(test)]
 
 use crate::{Trait, *};
-pub use primitives::{map, Blake2Hasher, H256};
-use rstd::prelude::*;
+use rstd::map;
 
-/// DIRTY IMPORT BECAUSE
-/// InputValidationLengthConstraint has not been factored out yet!!!
 use common::constraints::InputValidationLengthConstraint;
 
-/// The way a map (linked_map) is represented in the GenesisConfig produced by decl_storage
-//pub type GenesisConfigMap<K, V> = std::vec::Vec<(K, V)>;
-
 /// Builder of genesis configuration of content working group.
 pub struct GenesisConfigBuilder<T: Trait> {
     mint_capacity: minting::BalanceOf<T>,
-    /*
-    lead_by_id: GenesisConfigMap<LeadId<T>, Lead<T::AccountId, T::RewardRelationshipId, T::BlockNumber>>,
-    next_lead_id: LeadId<T>,
-    curator_opening_by_id: GenesisConfigMap<CuratorOpeningId<T>, CuratorOpening<T::OpeningId, T::BlockNumber, BalanceOf<T>, CuratorApplicationId<T>>>,
-    next_curator_opening_id: CuratorOpeningId<T>,
-    curator_application_by_id: GenesisConfigMap<CuratorApplicationId<T>, CuratorApplication<T::AccountId, CuratorOpeningId<T>, T::MemberId, T::ApplicationId>>,
-    next_curator_application_id: CuratorApplicationId<T>,
-    channel_by_id: GenesisConfigMap<ChannelId<T>, Channel<T::MemberId, T::AccountId, T::BlockNumber, PrincipalId<T>>>,
-    next_channel_id: ChannelId<T>,
-    channel_id_by_handle: GenesisConfigMap<Vec<u8>, ChannelId<T>>,
-    curator_by_id: GenesisConfigMap<CuratorId<T>, Curator<T::AccountId, T::RewardRelationshipId, T::StakeId, T::BlockNumber, LeadId<T>, CuratorApplicationId<T>, PrincipalId<T>>>,
-    next_curator_id: CuratorId<T>,
-    principal_by_id: GenesisConfigMap<PrincipalId<T>, Principal<CuratorId<T>, ChannelId<T>>>,
-    next_principal_id: PrincipalId<T>,
-
-    unstaker_by_stake_id: GenesisConfigMap<TestStakeId, WorkingGroupUnstaker<LeadId<T>, CuratorId<T>>>,
-    */
     channel_creation_enabled: bool,
     channel_handle_constraint: InputValidationLengthConstraint,
     channel_description_constraint: InputValidationLengthConstraint,
@@ -47,20 +24,7 @@ impl<T: Trait> GenesisConfigBuilder<T> {
         self.mint_capacity = capacity;
         self
     }
-    /*
-    pub fn set_channel_handle_constraint(mut self, constraint: InputValidationLengthConstraint) -> Self {
-        self.channel_description_constraint = constraint;
-        self
-    }
-    pub fn set_channel_description_constraint(mut self, constraint: InputValidationLengthConstraint) -> Self {
-        self.channel_description_constraint = constraint;
-        self
-    }
-    pub fn set_channel_creation_enabled(mut self, channel_creation_enabled: bool) -> Self {
-        self.channel_creation_enabled = channel_creation_enabled;
-        self
-    }
-    */
+
     pub fn build(self) -> GenesisConfig<T> {
         GenesisConfig {
             mint_capacity: self.mint_capacity,
@@ -68,7 +32,6 @@ impl<T: Trait> GenesisConfigBuilder<T> {
             next_curator_opening_id: CuratorOpeningId::<T>::default(),
             curator_application_by_id: map![], //GenesisConfigMap<CuratorApplicationId,CuratorApplication>,
             next_curator_application_id: CuratorApplicationId::<T>::default(),
-
             channel_by_id: map![], //GenesisConfigMap<ChannelId, Channel>,
             next_channel_id: ChannelId::<T>::default(),
             channel_id_by_handle: map![], //GenesisConfigMap<Vec<u8>, ChannelId>,
@@ -78,12 +41,10 @@ impl<T: Trait> GenesisConfigBuilder<T> {
             next_principal_id: PrincipalId::<T>::default(),
             channel_creation_enabled: self.channel_creation_enabled,
             unstaker_by_stake_id: map![], //GenesisConfigMap<LeadId, CuratorId>,
-
             channel_handle_constraint: self.channel_handle_constraint,
             channel_description_constraint: self.channel_description_constraint,
             curator_application_human_readable_text: self.curator_application_human_readable_text,
             curator_exit_rationale_text: self.curator_exit_rationale_text,
-
             channel_title_constraint: self.channel_title_constraint,
             channel_avatar_constraint: self.channel_avatar_constraint,
             channel_banner_constraint: self.channel_banner_constraint,
@@ -101,25 +62,6 @@ impl<T: Trait> Default for GenesisConfigBuilder<T> {
 
         Self {
             mint_capacity: minting::BalanceOf::<T>::from(10000),
-
-            /*
-            current_lead_id: LeadId::<T>::default(), //Option<LeadId>,
-            lead_by_id: map![], //GenesisConfigMap<LeadId, Lead>,
-            next_lead_id: 0,
-            curator_opening_by_id: map![], //GenesisConfigMap<CuratorOpeningId, Opening>,
-            next_curator_opening_id: 0,
-            curator_application_by_id: map![], //GenesisConfigMap<CuratorApplicationId,CuratorApplication>,
-            next_curator_application_id: 0,
-            channel_by_id: map![], //GenesisConfigMap<ChannelId, Channel>,
-            next_channel_id: 0,
-            channel_id_by_handle: map![], //GenesisConfigMap<Vec<u8>, ChannelId>,
-            curator_by_id: map![], //GenesisConfigMap<CuratorId, Curator>,
-            next_curator_id: 0,
-            principal_by_id: map![], //GenesisConfigMap<PrinicipalId, Prinicipal>,
-            next_principal_id: 0,
-
-            unstaker_by_stake_id: map![], //GenesisConfigMap<LeadId, CuratorId>,
-            */
             channel_creation_enabled: true,
             channel_handle_constraint: default_constraint.clone(),
             channel_description_constraint: default_constraint.clone(),

+ 89 - 79
runtime-modules/content-working-group/src/lib.rs

@@ -20,14 +20,10 @@ pub mod genesis;
 use serde::{Deserialize, Serialize};
 
 use codec::{Decode, Encode};
-use rstd::borrow::ToOwned;
-use rstd::collections::btree_map::BTreeMap;
-use rstd::collections::btree_set::BTreeSet;
-use rstd::convert::From;
-use rstd::prelude::*;
-use sr_primitives::traits::{One, Zero};
-use srml_support::traits::{Currency, ExistenceRequirement, WithdrawReasons};
-use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure};
+use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons};
+use frame_support::{decl_event, decl_module, decl_storage, ensure};
+use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
+use sp_arithmetic::traits::{One, Zero};
 use system::{self, ensure_root, ensure_signed};
 
 use common::constraints::InputValidationLengthConstraint;
@@ -42,8 +38,6 @@ pub trait Trait:
     + versioned_store_permissions::Trait
     + membership::Trait
 {
-    // + Sized
-
     /// The event type.
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
 }
@@ -93,6 +87,10 @@ pub type CuratorApplicationIdToCuratorIdMap<T> = BTreeMap<CuratorApplicationId<T
 // Workaround for BTreeSet type
 pub type CuratorApplicationIdSet<T> = BTreeSet<CuratorApplicationId<T>>;
 
+//TODO: Convert errors to the Substrate decl_error! macro.
+/// Result with string error message. This exists for backward compatibility purpose.
+pub type DispatchResult = Result<(), &'static str>;
+
 /*
  * MOVE ALL OF THESE OUT TO COMMON LATER
  */
@@ -718,10 +716,7 @@ pub struct OpeningPolicyCommitment<BlockNumber, Balance> {
     /// Staking policy for role itself
     pub role_staking_policy: Option<hiring::StakingPolicy<Balance, BlockNumber>>,
 
-    // Slashing terms during application
-    // pub application_slashing_terms: SlashingTerms,
-
-    // Slashing terms during role, NOT application itself!
+    /// Slashing terms during role, NOT application itself!
     pub role_slashing_terms: SlashingTerms,
 
     /// When filling an opening: Unstaking period for application stake of successful applicants
@@ -769,12 +764,6 @@ impl<LeadId: Default, CuratorId> Default for WorkingGroupUnstaker<LeadId, Curato
 // Move section below, this out in its own file later                       //
 // ======================================================================== //
 
-/*
-struct WrappedBeginAcceptingApplicationsError { // can this be made generic, or does that undermine the whole orhpan rule spirit?
-    pub error: hiring::BeginAcceptingApplicationsError
-}
-*/
-
 pub struct WrappedError<E> {
     // can this be made generic, or does that undermine the whole orhpan rule spirit?
     pub error: E,
@@ -783,7 +772,9 @@ pub struct WrappedError<E> {
 /// ....
 macro_rules! ensure_on_wrapped_error {
     ($call:expr) => {{
-        { $call }.map_err(|err| WrappedError { error: err })
+        { $call }
+            .map_err(|err| WrappedError { error: err })
+            .map_err(<&str>::from)
     }};
 }
 
@@ -974,83 +965,83 @@ decl_storage! {
     trait Store for Module<T: Trait> as ContentWorkingGroup {
 
         /// The mint currently funding the rewards for this module.
-        pub Mint get(mint) : <T as minting::Trait>::MintId;
+        pub Mint get(fn mint) : <T as minting::Trait>::MintId;
 
         /// The current lead.
-        pub CurrentLeadId get(current_lead_id) : Option<LeadId<T>>;
+        pub CurrentLeadId get(fn current_lead_id) : Option<LeadId<T>>;
 
         /// Maps identifier to corresponding lead.
-        pub LeadById get(lead_by_id): linked_map LeadId<T> => Lead<T::AccountId, T::RewardRelationshipId, T::BlockNumber, T::MemberId>;
+        pub LeadById get(fn lead_by_id): map hasher(blake2_128_concat)
+            LeadId<T> => Lead<T::AccountId, T::RewardRelationshipId, T::BlockNumber, T::MemberId>;
 
         /// Next identifier for new current lead.
-        pub NextLeadId get(next_lead_id): LeadId<T>;
+        pub NextLeadId get(fn next_lead_id): LeadId<T>;
 
         /// Maps identifeir to curator opening.
-        pub CuratorOpeningById get(curator_opening_by_id) config(): linked_map CuratorOpeningId<T> => CuratorOpening<T::OpeningId, T::BlockNumber, BalanceOf<T>, CuratorApplicationId<T>>;
+        pub CuratorOpeningById get(fn curator_opening_by_id) config(): map hasher(blake2_128_concat)
+            CuratorOpeningId<T> => CuratorOpening<T::OpeningId, T::BlockNumber, BalanceOf<T>, CuratorApplicationId<T>>;
 
         /// Next identifier valuefor new curator opening.
-        pub NextCuratorOpeningId get(next_curator_opening_id) config(): CuratorOpeningId<T>;
+        pub NextCuratorOpeningId get(fn next_curator_opening_id) config(): CuratorOpeningId<T>;
 
         /// Maps identifier to curator application on opening.
-        pub CuratorApplicationById get(curator_application_by_id) config(): linked_map CuratorApplicationId<T> => CuratorApplication<T::AccountId, CuratorOpeningId<T>, T::MemberId, T::ApplicationId>;
+        pub CuratorApplicationById get(fn curator_application_by_id) config(): map hasher(blake2_128_concat)
+            CuratorApplicationId<T> => CuratorApplication<T::AccountId, CuratorOpeningId<T>, T::MemberId, T::ApplicationId>;
 
         /// Next identifier value for new curator application.
-        pub NextCuratorApplicationId get(next_curator_application_id) config(): CuratorApplicationId<T>;
+        pub NextCuratorApplicationId get(fn next_curator_application_id) config(): CuratorApplicationId<T>;
 
         /// Maps identifier to corresponding channel.
-        pub ChannelById get(channel_by_id) config(): linked_map ChannelId<T> => Channel<T::MemberId, T::AccountId, T::BlockNumber, PrincipalId<T>>;
+        pub ChannelById get(fn channel_by_id) config(): map hasher(blake2_128_concat)
+            ChannelId<T> => Channel<T::MemberId, T::AccountId, T::BlockNumber, PrincipalId<T>>;
 
         /// Identifier to be used by the next channel introduced.
-        pub NextChannelId get(next_channel_id) config(): ChannelId<T>;
+        pub NextChannelId get(fn next_channel_id) config(): ChannelId<T>;
 
         /// Maps (unique) channel handle to the corresponding identifier for the channel.
         /// Mapping is required to allow efficient (O(log N)) on-chain verification that a proposed handle is indeed unique
         /// at the time it is being proposed.
-        pub ChannelIdByHandle get(channel_id_by_handle) config(): linked_map Vec<u8> => ChannelId<T>;
+        pub ChannelIdByHandle get(fn channel_id_by_handle) config(): map hasher(blake2_128_concat)
+            Vec<u8> => ChannelId<T>;
 
         /// Maps identifier to corresponding curator.
-        pub CuratorById get(curator_by_id) config(): linked_map CuratorId<T> => Curator<T::AccountId, T::RewardRelationshipId, T::StakeId, T::BlockNumber, LeadId<T>, CuratorApplicationId<T>, PrincipalId<T>>;
+        pub CuratorById get(fn curator_by_id) config(): map hasher(blake2_128_concat)
+            CuratorId<T> => Curator<T::AccountId, T::RewardRelationshipId, T::StakeId, T::BlockNumber, LeadId<T>, CuratorApplicationId<T>, PrincipalId<T>>;
 
         /// Next identifier for new curator.
-        pub NextCuratorId get(next_curator_id) config(): CuratorId<T>;
+        pub NextCuratorId get(fn next_curator_id) config(): CuratorId<T>;
 
         /// Maps identifier to principal.
-        pub PrincipalById get(principal_by_id) config(): linked_map PrincipalId<T> => Principal<CuratorId<T>, ChannelId<T>>;
+        pub PrincipalById get(fn principal_by_id) config(): map hasher(blake2_128_concat)
+            PrincipalId<T> => Principal<CuratorId<T>, ChannelId<T>>;
 
         /// Next identifier for
-        pub NextPrincipalId get(next_principal_id) config(): PrincipalId<T>;
+        pub NextPrincipalId get(fn next_principal_id) config(): PrincipalId<T>;
 
         /// Whether it is currently possible to create a channel via `create_channel` extrinsic.
-        pub ChannelCreationEnabled get(channel_creation_enabled) config(): bool;
+        pub ChannelCreationEnabled get(fn channel_creation_enabled) config(): bool;
 
         /// Recover curator by the role stake which is currently unstaking.
-        pub UnstakerByStakeId get(unstaker_by_stake_id) config(): linked_map StakeId<T> => WorkingGroupUnstaker<LeadId<T>, CuratorId<T>>;
-
-        // Limits
-
-        /// Limits the total number of curators which can be active.
-        //pub MaxSimultanouslyActiveCurators get(max_simultanously_active_curators) config(): Option<u16>;
+        pub UnstakerByStakeId get(fn unstaker_by_stake_id) config(): map hasher(blake2_128_concat)
+            StakeId<T> => WorkingGroupUnstaker<LeadId<T>, CuratorId<T>>;
 
-        // Limits the total number of openings which are not yet deactivated.
-        // pub MaxSimultaneouslyActiveOpenings get(max_simultaneously_active_openings) config(): Option<u16>,
 
         // Vector length input guards
-
-        pub ChannelHandleConstraint get(channel_handle_constraint) config(): InputValidationLengthConstraint;
-        pub ChannelTitleConstraint get(channel_title_constraint) config(): InputValidationLengthConstraint;
-        pub ChannelDescriptionConstraint get(channel_description_constraint) config(): InputValidationLengthConstraint;
-        pub ChannelAvatarConstraint get(channel_avatar_constraint) config(): InputValidationLengthConstraint;
-        pub ChannelBannerConstraint get(channel_banner_constraint) config(): InputValidationLengthConstraint;
-        pub OpeningHumanReadableText get(opening_human_readable_text) config(): InputValidationLengthConstraint;
-        pub CuratorApplicationHumanReadableText get(curator_application_human_readable_text) config(): InputValidationLengthConstraint;
-        pub CuratorExitRationaleText get(curator_exit_rationale_text) config(): InputValidationLengthConstraint;
+        pub ChannelHandleConstraint get(fn channel_handle_constraint) config(): InputValidationLengthConstraint;
+        pub ChannelTitleConstraint get(fn channel_title_constraint) config(): InputValidationLengthConstraint;
+        pub ChannelDescriptionConstraint get(fn channel_description_constraint) config(): InputValidationLengthConstraint;
+        pub ChannelAvatarConstraint get(fn channel_avatar_constraint) config(): InputValidationLengthConstraint;
+        pub ChannelBannerConstraint get(fn channel_banner_constraint) config(): InputValidationLengthConstraint;
+        pub OpeningHumanReadableText get(fn opening_human_readable_text) config(): InputValidationLengthConstraint;
+        pub CuratorApplicationHumanReadableText get(fn curator_application_human_readable_text) config(): InputValidationLengthConstraint;
+        pub CuratorExitRationaleText get(fn curator_exit_rationale_text) config(): InputValidationLengthConstraint;
     }
     add_extra_genesis {
         config(mint_capacity): minting::BalanceOf<T>;
-        // config(mint_adjustment): minting::Adjustment<BalanceOf<T>, T::BlockNumber> (add serialize/deserialize derivation for type)
         build(|config: &GenesisConfig<T>| {
             // create mint
-            let mint_id = <minting::Module<T>>::add_mint(config.mint_capacity, None).expect("Failed to create a mint for the content working group");
+            let mint_id = <minting::Module<T>>::add_mint(config.mint_capacity, None)
+                .expect("Failed to create a mint for the content working group");
             Mint::<T>::put(mint_id);
         });
     }
@@ -1075,7 +1066,7 @@ decl_event! {
         CuratorOpeningAdded(CuratorOpeningId),
         AcceptedCuratorApplications(CuratorOpeningId),
         BeganCuratorApplicationReview(CuratorOpeningId),
-        CuratorOpeningFilled(CuratorOpeningId, CuratorApplicationIdToCuratorIdMap), //BTreeSet<CuratorApplicationId>),
+        CuratorOpeningFilled(CuratorOpeningId, CuratorApplicationIdToCuratorIdMap),
         TerminatedCurator(CuratorId),
         AppliedOnCuratorOpening(CuratorOpeningId, CuratorApplicationId),
         CuratorExited(CuratorId),
@@ -1101,6 +1092,7 @@ decl_module! {
          */
 
         /// Create a new channel.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn create_channel(
             origin,
             owner: T::MemberId,
@@ -1187,6 +1179,7 @@ decl_module! {
         /// Notice that working group participants cannot do this.
         /// Notice that censored or unlisted channel may still be transferred.
         /// Notice that transfers are unilateral, so new owner cannot block. This may be problematic: https://github.com/Joystream/substrate-runtime-joystream/issues/95
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn transfer_channel_ownership(origin, channel_id: ChannelId<T>, new_owner: T::MemberId, new_role_account: T::AccountId) {
 
             // Ensure channel owner has signed
@@ -1211,6 +1204,7 @@ decl_module! {
         }
 
         /// Channel owner updates some channel properties
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_channel_as_owner(
             origin,
             channel_id: ChannelId<T>,
@@ -1268,6 +1262,7 @@ decl_module! {
         }
 
         /// Update channel as a curation actor
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_channel_as_curation_actor(
             origin,
             curation_actor: CurationActor<CuratorId<T>>,
@@ -1297,6 +1292,7 @@ decl_module! {
         }
 
         /// Add an opening for a curator role.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn add_curator_opening(origin, activate_at: hiring::ActivateOpeningAt<T::BlockNumber>, commitment: OpeningPolicyCommitment<T::BlockNumber, BalanceOf<T>>, human_readable_text: Vec<u8>)  {
 
             // Ensure lead is set and is origin signer
@@ -1344,6 +1340,7 @@ decl_module! {
         }
 
         /// Begin accepting curator applications to an opening that is active.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn accept_curator_applications(origin, curator_opening_id: CuratorOpeningId<T>)  {
 
             // Ensure lead is set and is origin signer
@@ -1370,6 +1367,7 @@ decl_module! {
         }
 
         /// Begin reviewing, and therefore not accepting new applications.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn begin_curator_applicant_review(origin, curator_opening_id: CuratorOpeningId<T>) {
 
             // Ensure lead is set and is origin signer
@@ -1396,6 +1394,7 @@ decl_module! {
         }
 
         /// Fill opening for curator
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn fill_curator_opening(
             origin,
             curator_opening_id: CuratorOpeningId<T>,
@@ -1414,7 +1413,7 @@ decl_module! {
                 let mint_id = Self::mint();
 
                 // Technically this is a bug-check and should not be here.
-                ensure!(<minting::Mints<T>>::exists(mint_id), MSG_FILL_CURATOR_OPENING_MINT_DOES_NOT_EXIST);
+                ensure!(<minting::Mints<T>>::contains_key(mint_id), MSG_FILL_CURATOR_OPENING_MINT_DOES_NOT_EXIST);
 
                 // Make sure valid parameters are selected for next payment at block number
                 ensure!(policy.next_payment_at_block > <system::Module<T>>::block_number(), MSG_FILL_CURATOR_OPENING_INVALID_NEXT_PAYMENT_BLOCK);
@@ -1555,6 +1554,7 @@ decl_module! {
 
         }
 
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn withdraw_curator_application(
             origin,
             curator_application_id: CuratorApplicationId<T>
@@ -1591,6 +1591,7 @@ decl_module! {
         }
 
         /// Lead terminate curator application
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn terminate_curator_application(
             origin,
             curator_application_id: CuratorApplicationId<T>
@@ -1621,6 +1622,7 @@ decl_module! {
         }
 
         /// Apply on a curator opening.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn apply_on_curator_opening(
             origin,
             member_id: T::MemberId,
@@ -1709,6 +1711,7 @@ decl_module! {
         }
 
         /// An active curator can update the associated role account.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_curator_role_account(
             origin,
             member_id: T::MemberId,
@@ -1736,6 +1739,7 @@ decl_module! {
 
         /// An active curator can update the reward account associated
         /// with a set reward relationship.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_curator_reward_account(
             origin,
             curator_id: CuratorId<T>,
@@ -1767,6 +1771,7 @@ decl_module! {
         }
 
         /// An active curator leaves role
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn leave_curator_role(
             origin,
             curator_id: CuratorId<T>,
@@ -1788,6 +1793,7 @@ decl_module! {
         }
 
         /// Lead can terminate and active curator
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn terminate_curator_role(
             origin,
             curator_id: CuratorId<T>,
@@ -1819,6 +1825,7 @@ decl_module! {
         /// If a value is provided for new_lead it will then set that new lead.
         /// It is responsibility of the caller to ensure the new lead can be set
         /// to avoid the lead role being vacant at the end of the call.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn replace_lead(origin, new_lead: Option<(T::MemberId, T::AccountId)>) {
             // Ensure root is origin
             ensure_root(origin)?;
@@ -1835,6 +1842,7 @@ decl_module! {
         }
 
         /// Add an opening for a curator role.
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn set_channel_creation_enabled(origin, enabled: bool)  {
 
             // Ensure lead is set and is origin signer
@@ -1856,6 +1864,7 @@ decl_module! {
         /// both increase and decrease capacity. Although when considering that it may be executed
         /// by a proposal, given the temporal delay in approving a proposal, it might be more suitable
         /// than set_mint_capacity?
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn increase_mint_capacity(
             origin,
             additional_capacity: minting::BalanceOf<T>
@@ -1865,7 +1874,7 @@ decl_module! {
             let mint_id = Self::mint();
             let mint = <minting::Module<T>>::mints(mint_id); // must exist
             let new_capacity = mint.capacity() + additional_capacity;
-            <minting::Module<T>>::set_mint_capacity(mint_id, new_capacity)?;
+            <minting::Module<T>>::set_mint_capacity(mint_id, new_capacity).map_err(<&str>::from)?;
 
             Self::deposit_event(RawEvent::MintCapacityIncreased(
                 mint_id, additional_capacity, new_capacity
@@ -1873,6 +1882,7 @@ decl_module! {
         }
 
         /// Sets the capacity of the current active mint
+        #[weight = 10_000_000] // TODO: adjust weight
         pub fn set_mint_capacity(
             origin,
             new_capacity: minting::BalanceOf<T>
@@ -1890,7 +1900,7 @@ decl_module! {
 
             if new_capacity != current_capacity {
                 // Cannot fail if mint exists
-                <minting::Module<T>>::set_mint_capacity(mint_id, new_capacity)?;
+                <minting::Module<T>>::set_mint_capacity(mint_id, new_capacity).map_err(<&str>::from)?;
 
                 if new_capacity > current_capacity {
                     Self::deposit_event(RawEvent::MintCapacityIncreased(
@@ -1902,7 +1912,6 @@ decl_module! {
                     ));
                 }
             }
-
         }
     }
 }
@@ -1910,7 +1919,7 @@ decl_module! {
 impl<T: Trait> versioned_store_permissions::CredentialChecker<T> for Module<T> {
     fn account_has_credential(account: &T::AccountId, id: PrincipalId<T>) -> bool {
         // Check that principal exists
-        if !PrincipalById::<T>::exists(&id) {
+        if !PrincipalById::<T>::contains_key(&id) {
             return false;
         }
 
@@ -1950,7 +1959,7 @@ impl<T: Trait> versioned_store_permissions::CredentialChecker<T> for Module<T> {
 
 impl<T: Trait> Module<T> {
     /// Introduce a lead when one is not currently set.
-    fn set_lead(member: T::MemberId, role_account: T::AccountId) -> dispatch::Result {
+    fn set_lead(member: T::MemberId, role_account: T::AccountId) -> DispatchResult {
         // Ensure there is no current lead
         ensure!(
             <CurrentLeadId<T>>::get().is_none(),
@@ -1988,7 +1997,7 @@ impl<T: Trait> Module<T> {
     }
 
     /// Evict the currently set lead
-    fn unset_lead() -> dispatch::Result {
+    fn unset_lead() -> DispatchResult {
         // Ensure there is a lead set
         let (lead_id, lead) = Self::ensure_lead_is_set()?;
 
@@ -2039,7 +2048,7 @@ impl<T: Trait> Module<T> {
     }
 
     // TODO: convert InputConstraint ensurer routines into macroes
-    fn ensure_channel_handle_is_valid(handle: &[u8]) -> dispatch::Result {
+    fn ensure_channel_handle_is_valid(handle: &[u8]) -> DispatchResult {
         ChannelHandleConstraint::get().ensure_valid(
             handle.len(),
             MSG_CHANNEL_HANDLE_TOO_SHORT,
@@ -2048,14 +2057,14 @@ impl<T: Trait> Module<T> {
 
         // Has to not already be occupied
         ensure!(
-            !ChannelIdByHandle::<T>::exists(handle),
+            !ChannelIdByHandle::<T>::contains_key(handle),
             MSG_CHANNEL_HANDLE_ALREADY_TAKEN
         );
 
         Ok(())
     }
 
-    fn ensure_channel_title_is_valid(text_opt: &OptionalText) -> dispatch::Result {
+    fn ensure_channel_title_is_valid(text_opt: &OptionalText) -> DispatchResult {
         if let Some(text) = text_opt {
             ChannelTitleConstraint::get().ensure_valid(
                 text.len(),
@@ -2067,7 +2076,7 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn ensure_channel_description_is_valid(text_opt: &OptionalText) -> dispatch::Result {
+    fn ensure_channel_description_is_valid(text_opt: &OptionalText) -> DispatchResult {
         if let Some(text) = text_opt {
             ChannelDescriptionConstraint::get().ensure_valid(
                 text.len(),
@@ -2079,7 +2088,7 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn ensure_channel_avatar_is_valid(text_opt: &OptionalText) -> dispatch::Result {
+    fn ensure_channel_avatar_is_valid(text_opt: &OptionalText) -> DispatchResult {
         if let Some(text) = text_opt {
             ChannelAvatarConstraint::get().ensure_valid(
                 text.len(),
@@ -2091,7 +2100,7 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn ensure_channel_banner_is_valid(text_opt: &OptionalText) -> dispatch::Result {
+    fn ensure_channel_banner_is_valid(text_opt: &OptionalText) -> DispatchResult {
         if let Some(text) = text_opt {
             ChannelBannerConstraint::get().ensure_valid(
                 text.len(),
@@ -2103,7 +2112,7 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn ensure_curator_application_text_is_valid(text: &[u8]) -> dispatch::Result {
+    fn ensure_curator_application_text_is_valid(text: &[u8]) -> DispatchResult {
         CuratorApplicationHumanReadableText::get().ensure_valid(
             text.len(),
             MSG_CURATOR_APPLICATION_TEXT_TOO_SHORT,
@@ -2111,7 +2120,7 @@ impl<T: Trait> Module<T> {
         )
     }
 
-    fn ensure_curator_exit_rationale_text_is_valid(text: &[u8]) -> dispatch::Result {
+    fn ensure_curator_exit_rationale_text_is_valid(text: &[u8]) -> DispatchResult {
         CuratorExitRationaleText::get().ensure_valid(
             text.len(),
             MSG_CURATOR_EXIT_RATIONALE_TEXT_TOO_SHORT,
@@ -2119,7 +2128,7 @@ impl<T: Trait> Module<T> {
         )
     }
 
-    fn ensure_opening_human_readable_text_is_valid(text: &[u8]) -> dispatch::Result {
+    fn ensure_opening_human_readable_text_is_valid(text: &[u8]) -> DispatchResult {
         OpeningHumanReadableText::get().ensure_valid(
             text.len(),
             MSG_CHANNEL_DESCRIPTION_TOO_SHORT,
@@ -2131,7 +2140,7 @@ impl<T: Trait> Module<T> {
         channel_id: &ChannelId<T>,
     ) -> Result<Channel<T::MemberId, T::AccountId, T::BlockNumber, PrincipalId<T>>, &'static str>
     {
-        if ChannelById::<T>::exists(channel_id) {
+        if ChannelById::<T>::contains_key(channel_id) {
             let channel = ChannelById::<T>::get(channel_id);
 
             Ok(channel)
@@ -2198,7 +2207,7 @@ impl<T: Trait> Module<T> {
         &'static str,
     > {
         ensure!(
-            CuratorOpeningById::<T>::exists(curator_opening_id),
+            CuratorOpeningById::<T>::contains_key(curator_opening_id),
             MSG_CURATOR_OPENING_DOES_NOT_EXIST
         );
 
@@ -2224,7 +2233,7 @@ impl<T: Trait> Module<T> {
         &'static str,
     > {
         ensure!(
-            CuratorById::<T>::exists(curator_id),
+            CuratorById::<T>::contains_key(curator_id),
             MSG_CURATOR_DOES_NOT_EXIST
         );
 
@@ -2237,7 +2246,7 @@ impl<T: Trait> Module<T> {
         stake_id: &StakeId<T>,
     ) -> Result<WorkingGroupUnstaker<LeadId<T>, CuratorId<T>>, &'static str> {
         ensure!(
-            UnstakerByStakeId::<T>::exists(stake_id),
+            UnstakerByStakeId::<T>::contains_key(stake_id),
             MSG_UNSTAKER_DOES_NOT_EXIST
         );
 
@@ -2353,7 +2362,7 @@ impl<T: Trait> Module<T> {
         &'static str,
     > {
         ensure!(
-            CuratorApplicationById::<T>::exists(curator_application_id),
+            CuratorApplicationById::<T>::contains_key(curator_application_id),
             MSG_CURATOR_APPLICATION_DOES_NOT_EXIST
         );
 
@@ -2424,6 +2433,7 @@ impl<T: Trait> Module<T> {
                     WithdrawReasons::all(),
                     new_balance,
                 )
+                .map_err(<&str>::from)
             }
         } else {
             Ok(())
@@ -2613,7 +2623,7 @@ impl<T: Trait> Module<T> {
     /// to this module.
     pub fn unstaked(stake_id: StakeId<T>) {
         // Ignore if unstaked doesn't exist
-        if !<UnstakerByStakeId<T>>::exists(stake_id) {
+        if !<UnstakerByStakeId<T>>::contains_key(stake_id) {
             return;
         }
 

+ 36 - 31
runtime-modules/content-working-group/src/mock.rs

@@ -1,18 +1,16 @@
 #![cfg(test)]
 
 pub use crate::*;
-pub use srml_support::traits::Currency;
-pub use system;
 
-pub use primitives::{map, Blake2Hasher, H256};
-pub use sr_primitives::{
-    testing::{Digest, DigestItem, Header, UintAuthorityId},
-    traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize},
-    weights::Weight,
-    BuildStorage, Perbill,
+use frame_support::traits::{OnFinalize, OnInitialize};
+use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
+use sp_core::H256;
+use sp_runtime::{
+    testing::Header,
+    traits::{BlakeTwo256, IdentityLookup},
+    Perbill,
 };
-
-use srml_support::{impl_outer_event, impl_outer_origin, parameter_types};
+pub use system;
 
 pub use common::currency::GovernanceCurrency;
 pub use hiring;
@@ -32,10 +30,6 @@ parameter_types! {
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const MinimumPeriod: u64 = 5;
     pub const ExistentialDeposit: u32 = 0;
-    pub const TransferFee: u32 = 0;
-    pub const CreationFee: u32 = 0;
-    pub const TransactionBaseFee: u32 = 1;
-    pub const TransactionByteFee: u32 = 0;
     pub const StakePoolId: [u8; 8] = *b"joystake";
 }
 
@@ -56,6 +50,7 @@ impl_outer_event! {
         versioned_store<T>,
         membership<T>,
         balances<T>,
+        system<T>,
         lib<T>,
     }
 }
@@ -80,24 +75,31 @@ pub fn get_last_event_or_panic() -> RawLibTestEvent {
     }
 }
 
-type TestAccountId = u64;
-type TestBlockNumber = u64;
 impl system::Trait for Test {
+    type BaseCallFilter = ();
     type Origin = Origin;
-    type Index = u64;
-    type BlockNumber = TestBlockNumber;
     type Call = ();
+    type Index = u64;
+    type BlockNumber = u64;
     type Hash = H256;
     type Hashing = BlakeTwo256;
-    type AccountId = TestAccountId;
+    type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
     type Event = TestEvent;
     type BlockHashCount = BlockHashCount;
     type MaximumBlockWeight = MaximumBlockWeight;
+    type DbWeight = ();
+    type BlockExecutionWeight = ();
+    type ExtrinsicBaseWeight = ();
+    type MaximumExtrinsicWeight = ();
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
+    type ModuleToIndex = ();
+    type AccountData = balances::AccountData<u64>;
+    type OnNewAccount = ();
+    type OnKilledAccount = ();
 }
 
 impl timestamp::Trait for Test {
@@ -107,20 +109,11 @@ impl timestamp::Trait for Test {
 }
 
 impl balances::Trait for Test {
-    /// The type for recording an account's balance.
     type Balance = u64;
-    /// What to do if an account's free balance gets zeroed.
-    type OnFreeBalanceZero = ();
-    /// What to do if a new account is created.
-    type OnNewAccount = ();
-    /// The ubiquitous event type.
-    type Event = TestEvent;
-
     type DustRemoval = ();
-    type TransferPayment = ();
+    type Event = TestEvent;
     type ExistentialDeposit = ExistentialDeposit;
-    type TransferFee = TransferFee;
-    type CreationFee = CreationFee;
+    type AccountStore = System;
 }
 
 impl GovernanceCurrency for Test {
@@ -206,7 +199,7 @@ impl<T: Trait> TestExternalitiesBuilder<T> {
         self
     }
 
-    pub fn build(self) -> runtime_io::TestExternalities {
+    pub fn build(self) -> sp_io::TestExternalities {
         // Add system
         let mut t = self
             .system_config
@@ -241,3 +234,15 @@ pub type System = system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type ContentWorkingGroup = Module<Test>;
 pub type Minting = minting::Module<Test>;
+
+// Recommendation from Parity on testing on_finalize
+// https://substrate.dev/docs/en/next/development/module/tests
+pub fn run_to_block(n: u64) {
+    while System::block_number() < n {
+        <System as OnFinalize<u64>>::on_finalize(System::block_number());
+        <ContentWorkingGroup as OnFinalize<u64>>::on_finalize(System::block_number());
+        System::set_block_number(System::block_number() + 1);
+        <System as OnInitialize<u64>>::on_initialize(System::block_number());
+        <ContentWorkingGroup as OnInitialize<u64>>::on_initialize(System::block_number());
+    }
+}

+ 0 - 6
runtime-modules/content-working-group/src/mod.rs

@@ -1,6 +0,0 @@
-pub mod genesis;
-pub mod lib;
-//pub mod types;
-
-mod mock;
-mod tests;

+ 78 - 61
runtime-modules/content-working-group/src/tests.rs

@@ -2,19 +2,27 @@
 
 use super::genesis;
 use super::mock::{self, *};
-use hiring;
-use rstd::collections::btree_map::BTreeMap;
-use rstd::collections::btree_set::BTreeSet;
-use sr_primitives::traits::One;
-use srml_support::{assert_err, assert_ok, StorageLinkedMap, StorageValue};
+
+use frame_support::{assert_err, assert_ok, traits::Currency, StorageValue};
+use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
+use sp_arithmetic::traits::One;
+use system::RawOrigin;
 
 use common::constraints::InputValidationLengthConstraint;
+use hiring;
 
 #[test]
 fn create_channel_success() {
     TestExternalitiesBuilder::<Test>::default()
         .build()
         .execute_with(|| {
+            /*
+               Events are not emitted on block 0.
+               So any dispatchable calls made during genesis block formation will have no events emitted.
+               https://substrate.dev/recipes/2-appetizers/4-events.html
+            */
+            run_to_block(1);
+
             // Add channel creator as member
             let channel_creator_member_root_and_controller_account = 12312;
 
@@ -171,6 +179,13 @@ fn transfer_channel_ownership_success() {
     TestExternalitiesBuilder::<Test>::default()
         .build()
         .execute_with(|| {
+            /*
+               Events are not emitted on block 0.
+               So any dispatchable calls made during genesis block formation will have no events emitted.
+               https://substrate.dev/recipes/2-appetizers/4-events.html
+            */
+            run_to_block(1);
+
             // Add channel creator as member
             let channel_creator_member_root_and_controller_account_1 = 1111;
             let channel_creator_member_root_and_controller_account_2 = 2222;
@@ -242,6 +257,7 @@ impl UpdateChannelAsCurationActorFixture {
             self.new_verified,
             self.new_curation_status,
         )
+        .map_err(<&str>::from)
     }
 
     pub fn call_and_assert_success(&self, channel_id: ChannelId<Test>) {
@@ -284,7 +300,7 @@ impl UpdateChannelAsCurationActorFixture {
         assert_eq!(event_channel_id, channel_id);
 
         // Channel has been updated correctly
-        assert!(ChannelById::<Test>::exists(channel_id));
+        assert!(ChannelById::<Test>::contains_key(channel_id));
 
         let updated_channel = ChannelById::<Test>::get(channel_id);
 
@@ -394,7 +410,7 @@ fn add_curator_opening_success() {
 
             // Assert that given opening id has been added,
             // and has the right properties.
-            assert!(crate::CuratorOpeningById::<Test>::exists(
+            assert!(crate::CuratorOpeningById::<Test>::contains_key(
                 expected_curator_opening_id
             ));
 
@@ -748,7 +764,7 @@ fn apply_on_curator_opening_success() {
                 )
             );
 
-            assert!(CuratorApplicationById::<Test>::exists(
+            assert!(CuratorApplicationById::<Test>::contains_key(
                 new_curator_application_id
             ));
 
@@ -874,6 +890,7 @@ impl UpdateCuratorRoleAccountFixture {
             self.curator_id,
             self.new_role_account,
         )
+        .map_err(<&str>::from)
     }
 
     pub fn call_and_assert_success(&self) {
@@ -950,6 +967,7 @@ impl UpdateCuratorRewardAccountFixture {
             self.curator_id,
             self.new_reward_account,
         )
+        .map_err(<&str>::from)
     }
 
     #[allow(dead_code)] // delete if the method is unnecessary
@@ -1016,6 +1034,7 @@ impl LeaveCuratorRoleFixture {
             self.curator_id,
             self.rationale_text.clone(),
         )
+        .map_err(<&str>::from)
     }
 
     pub fn call_and_assert_success(&self) {
@@ -1046,7 +1065,9 @@ impl LeaveCuratorRoleFixture {
         // Tracking unstaking
         let curator_role_stake_id = original_curator.role_stake_profile.unwrap().stake_id;
 
-        assert!(UnstakerByStakeId::<Test>::exists(curator_role_stake_id));
+        assert!(UnstakerByStakeId::<Test>::contains_key(
+            curator_role_stake_id
+        ));
 
         let unstaker = UnstakerByStakeId::<Test>::get(curator_role_stake_id);
 
@@ -1089,6 +1110,7 @@ impl TerminateCuratorRoleFixture {
             self.curator_id,
             self.rationale_text.clone(),
         )
+        .map_err(<&str>::from)
     }
 
     pub fn call_and_assert_success(&self) {
@@ -1119,7 +1141,9 @@ impl TerminateCuratorRoleFixture {
         // Tracking unstaking
         let curator_role_stake_id = original_curator.role_stake_profile.unwrap().stake_id;
 
-        assert!(UnstakerByStakeId::<Test>::exists(curator_role_stake_id));
+        assert!(UnstakerByStakeId::<Test>::contains_key(
+            curator_role_stake_id
+        ));
 
         let unstaker = UnstakerByStakeId::<Test>::get(curator_role_stake_id);
 
@@ -1161,6 +1185,7 @@ impl SetLeadFixture {
             self.origin.clone(),
             Some((self.member_id, self.new_role_account)),
         )
+        .map_err(<&str>::from)
     }
 
     pub fn call_and_assert_success(&self) {
@@ -1204,11 +1229,18 @@ fn set_lead_success() {
     TestExternalitiesBuilder::<Test>::default()
         .build()
         .execute_with(|| {
+            /*
+               Events are not emitted on block 0.
+               So any dispatchable calls made during genesis block formation will have no events emitted.
+               https://substrate.dev/recipes/2-appetizers/4-events.html
+            */
+            run_to_block(1);
+
             let member_id =
                 add_member(LEAD_ROOT_AND_CONTROLLER_ACCOUNT, to_vec(LEAD_MEMBER_HANDLE));
 
             SetLeadFixture {
-                origin: Origin::system(system::RawOrigin::Root),
+                origin: RawOrigin::Root.into(),
                 member_id,
                 new_role_account: 44444,
             }
@@ -1222,7 +1254,7 @@ struct UnsetLeadFixture {
 
 impl UnsetLeadFixture {
     fn call(&self) -> Result<(), &'static str> {
-        ContentWorkingGroup::replace_lead(self.origin.clone(), None)
+        ContentWorkingGroup::replace_lead(self.origin.clone(), None).map_err(<&str>::from)
     }
 
     pub fn call_and_assert_success(&self) {
@@ -1261,7 +1293,7 @@ fn unset_lead_success() {
             let _ = add_member_and_set_as_lead();
 
             UnsetLeadFixture {
-                origin: Origin::system(system::RawOrigin::Root),
+                origin: RawOrigin::Root.into(),
             }
             .call_and_assert_success();
         });
@@ -1311,7 +1343,7 @@ impl UnstakedFixture {
         );
 
         // Unstaker gone
-        assert!(!UnstakerByStakeId::<Test>::exists(self.stake_id));
+        assert!(!UnstakerByStakeId::<Test>::contains_key(self.stake_id));
     }
 
     // pub fn call_and_assert_failed_result(&self, error_message: &'static str) {
@@ -1406,39 +1438,6 @@ pub fn to_vec(s: &str) -> Vec<u8> {
     s.as_bytes().to_vec()
 }
 
-/*
- * Setups
- */
-
-//type TestSeed = u128;
-
-/*
-fn account_from_seed(TestSeed: seed) -> <Test as system::Trait>::AccountId {
-
-}
-
-fn vector_from_seed(TestSeed: seed) {
-
-}
-*/
-
-/*
-static INITIAL_SEED_VALUE: u128 = 0;
-static CURRENT_SEED: u128 = INITIAL_SEED_VALUE;
-
-fn get_current_seed() {
-
-}
-
-fn update_seed() {
-
-}
-
-fn reset_seed() {
-    CURRENT_SEED: u128 = INITIAL_SEED_VALUE;
-}
-*/
-
 // MOVE THIS LATER WHEN fill_opening is factored out
 #[derive(Clone)]
 pub struct FillOpeningApplicantParams {
@@ -1568,7 +1567,7 @@ fn add_member_and_apply_on_opening(
         crate::RawEvent::AppliedOnCuratorOpening(curator_opening_id, new_curator_application_id)
     );
 
-    assert!(CuratorApplicationById::<Test>::exists(
+    assert!(CuratorApplicationById::<Test>::contains_key(
         new_curator_application_id
     ));
 
@@ -1718,7 +1717,6 @@ fn setup_and_fill_opening(
     let applicants_to_hire_iter = applicants.iter().filter(|params| params.hire);
 
     let num_applicants_hired = applicants_to_hire_iter.cloned().count();
-    //let num_applicants_not_to_hire = (applicants.len() - num_applicants_hired) as usize;
 
     let hired_applicant_and_result = setup_opening_in_review
         .added_members_application_result
@@ -1799,7 +1797,7 @@ fn setup_and_fill_opening(
         let expected_added_principal_id: u64 = (hired_index as u64) + original_next_principal_id;
 
         // Curator added
-        assert!(CuratorById::<Test>::exists(expected_added_curator_id));
+        assert!(CuratorById::<Test>::contains_key(expected_added_curator_id));
 
         let added_curator = CuratorById::<Test>::get(expected_added_curator_id);
 
@@ -1848,7 +1846,9 @@ fn setup_and_fill_opening(
         assert_eq!(expected_curator, added_curator);
 
         // Principal added
-        assert!(PrincipalById::<Test>::exists(expected_added_principal_id));
+        assert!(PrincipalById::<Test>::contains_key(
+            expected_added_principal_id
+        ));
 
         let added_principal = PrincipalById::<Test>::get(expected_added_principal_id);
 
@@ -1978,6 +1978,7 @@ impl CreateChannelFixture {
             self.banner.clone(),
             self.publication_status.clone(),
         )
+        .map_err(<&str>::from)
     }
 
     pub fn call_and_assert_error(&self, err_message: &'static str) {
@@ -2010,7 +2011,7 @@ impl CreateChannelFixture {
 
         // Assert that given channel id has been added,
         // and has the right properties.
-        assert!(crate::ChannelById::<Test>::exists(channel_id));
+        assert!(crate::ChannelById::<Test>::contains_key(channel_id));
 
         let created_channel = crate::ChannelById::<Test>::get(channel_id);
 
@@ -2044,7 +2045,7 @@ impl CreateChannelFixture {
         );
 
         // Check that principal actually has been added
-        assert!(crate::PrincipalById::<Test>::exists(
+        assert!(crate::PrincipalById::<Test>::contains_key(
             created_channel.principal_id
         ));
 
@@ -2113,15 +2114,18 @@ pub fn set_lead(
     member_id: <Test as membership::Trait>::MemberId,
     new_role_account: <Test as system::Trait>::AccountId,
 ) -> LeadId<Test> {
-    // Get controller account
-    //let lead_member_controller_account = membership::Module::<Test>::ensure_membership(member_id).unwrap().controller_account;
+    /*
+       Events are not emitted on block 0.
+       So any dispatchable calls made during genesis block formation will have no events emitted.
+       https://substrate.dev/recipes/2-appetizers/4-events.html
+    */
+    run_to_block(1);
 
     let expected_lead_id = NextLeadId::<Test>::get();
-
     // Set lead
     assert_eq!(
         ContentWorkingGroup::replace_lead(
-            mock::Origin::system(system::RawOrigin::Root),
+            RawOrigin::Root.into(),
             Some((member_id, new_role_account))
         )
         .unwrap(),
@@ -2136,7 +2140,6 @@ pub fn set_lead(
     expected_lead_id
 }
 
-// lead_role_account: <Test as system::Trait>::AccountId
 pub fn add_curator_opening() -> CuratorOpeningId<Test> {
     let activate_at = hiring::ActivateOpeningAt::ExactBlock(34);
 
@@ -2195,6 +2198,13 @@ fn increasing_mint_capacity() {
         )
         .build()
         .execute_with(|| {
+            /*
+               Events are not emitted on block 0.
+               So any dispatchable calls made during genesis block formation will have no events emitted.
+               https://substrate.dev/recipes/2-appetizers/4-events.html
+            */
+            run_to_block(1);
+
             let mint_id = ContentWorkingGroup::mint();
             let mint = Minting::mints(mint_id);
             assert_eq!(mint.capacity(), MINT_CAPACITY);
@@ -2203,7 +2213,7 @@ fn increasing_mint_capacity() {
             // Increasing mint capacity
             let expected_new_capacity = MINT_CAPACITY + increase;
             assert_ok!(ContentWorkingGroup::increase_mint_capacity(
-                Origin::ROOT,
+                RawOrigin::Root.into(),
                 increase
             ));
             // Excpected event after increasing
@@ -2229,6 +2239,13 @@ fn setting_mint_capacity() {
         )
         .build()
         .execute_with(|| {
+            /*
+               Events are not emitted on block 0.
+               So any dispatchable calls made during genesis block formation will have no events emitted.
+               https://substrate.dev/recipes/2-appetizers/4-events.html
+            */
+            run_to_block(1);
+
             let mint_id = ContentWorkingGroup::mint();
             let mint = Minting::mints(mint_id);
             assert_eq!(mint.capacity(), MINT_CAPACITY);
@@ -2237,7 +2254,7 @@ fn setting_mint_capacity() {
             let new_lower_capacity = 10000;
             let decrease = MINT_CAPACITY - new_lower_capacity;
             assert_ok!(ContentWorkingGroup::set_mint_capacity(
-                Origin::ROOT,
+                RawOrigin::Root.into(),
                 new_lower_capacity
             ));
             // Correct event after decreasing
@@ -2253,7 +2270,7 @@ fn setting_mint_capacity() {
             let new_higher_capacity = 25000;
             let increase = new_higher_capacity - mint.capacity();
             assert_ok!(ContentWorkingGroup::set_mint_capacity(
-                Origin::ROOT,
+                RawOrigin::Root.into(),
                 new_higher_capacity
             ));
             // Excpected event after increasing