Browse Source

Fix review comments

Shamil Gadelshin 4 years ago
parent
commit
2eebdfbe32

+ 1 - 1
Cargo.lock

@@ -4806,7 +4806,7 @@ dependencies = [
 
 [[package]]
 name = "substrate-forum-module"
-version = "1.2.1"
+version = "1.2.2"
 dependencies = [
  "hex-literal 0.1.4",
  "parity-scale-codec",

+ 5 - 2
node/src/chain_spec.rs

@@ -25,8 +25,8 @@ use node_runtime::{
     CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig,
     DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig,
     MembersConfig, MigrationConfig, Perbill, ProposalsCodexConfig, SessionConfig, SessionKeys,
-    Signature, StakerStatus, StakingConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS,
-    WASM_BINARY,
+    Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig,
+    VersionedStoreConfig, DAYS, WASM_BINARY,
 };
 pub use node_runtime::{AccountId, GenesisConfig};
 use primitives::{sr25519, Pair, Public};
@@ -267,6 +267,9 @@ pub fn testnet_genesis(
         }),
         data_object_storage_registry: Some(DataObjectStorageRegistryConfig {
             first_relationship_id: 1,
+        }),
+        working_group_Instance2: Some(StorageWorkingGroupConfig {
+            phantom: Default::default(),
             storage_working_group_mint_capacity: 0,
             opening_human_readable_text_constraint: default_text_constraint,
             worker_application_human_readable_text_constraint: default_text_constraint,

+ 1 - 1
node/src/forum_config/mod.rs

@@ -3,7 +3,7 @@ pub mod from_serialized;
 // Not exported - only here as sample code
 // mod from_encoded;
 
-use node_runtime::forum::InputValidationLengthConstraint;
+use node_runtime::common::constraints::InputValidationLengthConstraint;
 
 pub fn new_validation(min: u16, max_min_diff: u16) -> InputValidationLengthConstraint {
     InputValidationLengthConstraint { min, max_min_diff }

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

@@ -6,7 +6,7 @@ use rstd::prelude::*;
 
 /// DIRTY IMPORT BECAUSE
 /// InputValidationLengthConstraint has not been factored out yet!!!
-use forum::InputValidationLengthConstraint;
+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)>;

+ 1 - 3
runtime-modules/content-working-group/src/tests.rs

@@ -9,9 +9,7 @@ use rstd::collections::btree_set::BTreeSet;
 use sr_primitives::traits::One;
 use srml_support::{assert_err, assert_ok, StorageLinkedMap, StorageValue};
 
-/// DIRTY IMPORT BECAUSE
-/// InputValidationLengthConstraint has not been factored out yet!!!
-use forum::InputValidationLengthConstraint;
+use common::constraints::InputValidationLengthConstraint;
 
 #[test]
 fn create_channel_success() {

+ 1 - 1
runtime-modules/forum/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = 'substrate-forum-module'
-version = '1.2.1'
+version = '1.2.2'
 authors = ['Joystream contributors']
 edition = '2018'
 

+ 1 - 1
runtime-modules/forum/src/lib.rs

@@ -19,7 +19,7 @@ use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, Para
 mod mock;
 mod tests;
 
-pub use common::constraints::InputValidationLengthConstraint;
+use common::constraints::InputValidationLengthConstraint;
 use common::BlockAndTime;
 
 /// Constants

+ 6 - 3
runtime-modules/service-discovery/src/lib.rs

@@ -48,8 +48,11 @@ pub type IPNSIdentity = Vec<u8>;
 /// HTTP Url string to a discovery service endpoint
 pub type Url = Vec<u8>;
 
-// Alias for storage working group
-pub(crate) type StorageWorkingGroup<T> = working_group::Module<T, working_group::Instance2>;
+// The storage working group instance alias.
+pub(crate) type StorageWorkingGroupInstance = working_group::Instance2;
+
+// Alias for storage working group.
+pub(crate) type StorageWorkingGroup<T> = working_group::Module<T, StorageWorkingGroupInstance>;
 
 /// Storage provider is a worker from the  working_group module.
 pub type StorageProviderId<T> = working_group::WorkerId<T>;
@@ -68,7 +71,7 @@ pub struct AccountInfo<BlockNumber> {
 }
 
 /// The _Service discovery_ main _Trait_.
-pub trait Trait: system::Trait + working_group::Trait<working_group::Instance2> {
+pub trait Trait: system::Trait + working_group::Trait<StorageWorkingGroupInstance> {
     /// _Service discovery_ event type.
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
 }

+ 7 - 4
runtime-modules/service-discovery/src/mock.rs

@@ -11,9 +11,12 @@ pub use sr_primitives::{
 
 use srml_support::{impl_outer_event, impl_outer_origin, parameter_types};
 
+// The storage working group instance alias.
+pub type StorageWorkingGroupInstance = working_group::Instance2;
+
 mod working_group_mod {
+    pub use super::StorageWorkingGroupInstance;
     pub use working_group::Event;
-    pub use working_group::Instance2;
     pub use working_group::Trait;
 }
 
@@ -34,7 +37,7 @@ impl_outer_event! {
         discovery<T>,
         balances<T>,
         membership_mod<T>,
-         working_group_mod Instance2 <T>,
+         working_group_mod StorageWorkingGroupInstance <T>,
     }
 }
 
@@ -127,7 +130,7 @@ impl recurringrewards::Trait for Test {
     type RewardRelationshipId = u64;
 }
 
-impl working_group::Trait<working_group::Instance2> for Test {
+impl working_group::Trait<StorageWorkingGroupInstance> for Test {
     type Event = MetaEvent;
 }
 
@@ -160,7 +163,7 @@ pub(crate) fn hire_storage_provider() -> (u64, u64) {
         role_stake_profile: None,
     };
 
-    <working_group::WorkerById<Test, working_group::Instance2>>::insert(
+    <working_group::WorkerById<Test, StorageWorkingGroupInstance>>::insert(
         storage_provider_id,
         storage_provider,
     );

+ 5 - 6
runtime-modules/storage/Cargo.toml

@@ -17,7 +17,6 @@ std = [
 	'primitives/std',
 	'common/std',
 	'membership/std',
-	'minting/std',
 	'working-group/std',
 ]
 
@@ -74,11 +73,6 @@ default_features = false
 package = 'substrate-membership-module'
 path = '../membership'
 
-[dependencies.minting]
-default_features = false
-package = 'substrate-token-mint-module'
-path = '../token-minting'
-
 [dependencies.common]
 default_features = false
 package = 'substrate-common-module'
@@ -115,3 +109,8 @@ path = '../hiring'
 default_features = false
 package = 'substrate-stake-module'
 path = '../stake'
+
+[dev-dependencies.minting]
+default_features = false
+package = 'substrate-token-mint-module'
+path = '../token-minting'

+ 2 - 2
runtime-modules/storage/src/data_directory.rs

@@ -32,7 +32,7 @@ pub(crate) use common::BlockAndTime;
 
 use crate::data_object_type_registry;
 use crate::data_object_type_registry::IsActiveDataObjectType;
-use crate::{MemberId, StorageProviderId, StorageWorkingGroup};
+use crate::{MemberId, StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance};
 
 /// The _Data directory_ main _Trait_.
 pub trait Trait:
@@ -40,7 +40,7 @@ pub trait Trait:
     + system::Trait
     + data_object_type_registry::Trait
     + membership::members::Trait
-    + working_group::Trait<working_group::Instance2>
+    + working_group::Trait<StorageWorkingGroupInstance>
 {
     /// _Data directory_ event type.
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;

+ 3 - 35
runtime-modules/storage/src/data_object_storage_registry.rs

@@ -25,14 +25,10 @@
 use codec::{Codec, Decode, Encode};
 use rstd::prelude::*;
 use sr_primitives::traits::{MaybeSerialize, Member, SimpleArithmetic};
-use srml_support::{
-    decl_error, decl_event, decl_module, decl_storage, ensure, print, Parameter, StorageValue,
-};
-
-use common::constraints::InputValidationLengthConstraint;
+use srml_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter};
 
 use crate::data_directory::{self, ContentIdExists};
-use crate::{StorageProviderId, StorageWorkingGroup};
+use crate::{StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance};
 
 const DEFAULT_FIRST_RELATIONSHIP_ID: u32 = 1;
 
@@ -41,7 +37,7 @@ pub trait Trait:
     timestamp::Trait
     + system::Trait
     + data_directory::Trait
-    + working_group::Trait<working_group::Instance2>
+    + working_group::Trait<StorageWorkingGroupInstance>
 {
     /// _Data object storage registry_ event type.
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
@@ -125,34 +121,6 @@ decl_storage! {
         /// Keeps a list of storage relationships per content id.
         pub RelationshipsByContentId get(relationships_by_content_id): map T::ContentId => Vec<T::DataObjectStorageRelationshipId>;
     }
-    add_extra_genesis {
-        config(storage_working_group_mint_capacity): minting::BalanceOf<T>;
-        config(opening_human_readable_text_constraint): InputValidationLengthConstraint;
-        config(worker_application_human_readable_text_constraint): InputValidationLengthConstraint;
-        config(worker_exit_rationale_text_constraint): InputValidationLengthConstraint;
-        build(|config: &GenesisConfig<T>| {
-            // Create a mint.
-            let mint_id_result =
-                <minting::Module<T>>::add_mint(config.storage_working_group_mint_capacity, None);
-
-            if let Ok(mint_id) = mint_id_result {
-                <working_group::Mint::<T, working_group::Instance2>>::put(mint_id);
-            } else {
-                print("Failed to create a mint for the storage working group");
-            }
-
-            // Create constraints
-            <working_group::OpeningHumanReadableText::<working_group::Instance2>>::put(
-                config.opening_human_readable_text_constraint
-            );
-            <working_group::WorkerApplicationHumanReadableText::<working_group::Instance2>>::put(
-                config.worker_application_human_readable_text_constraint
-            );
-            <working_group::WorkerExitRationaleText::<working_group::Instance2>>::put(
-                config.worker_exit_rationale_text_constraint
-            );
-        });
-    }
 }
 
 decl_event! {

+ 2 - 2
runtime-modules/storage/src/data_object_type_registry.rs

@@ -22,7 +22,7 @@
 // Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue.
 //#![warn(missing_docs)]
 
-use crate::StorageWorkingGroup;
+use crate::{StorageWorkingGroup, StorageWorkingGroupInstance};
 use codec::{Codec, Decode, Encode};
 use rstd::prelude::*;
 use sr_primitives::traits::{MaybeSerialize, Member, SimpleArithmetic};
@@ -32,7 +32,7 @@ const DEFAULT_TYPE_DESCRIPTION: &str = "Default data object type for audio and v
 const DEFAULT_FIRST_DATA_OBJECT_TYPE_ID: u32 = 1;
 
 /// The _Data object type registry_ main _Trait_.
-pub trait Trait: system::Trait + working_group::Trait<working_group::Instance2> {
+pub trait Trait: system::Trait + working_group::Trait<StorageWorkingGroupInstance> {
     /// _Data object type registry_ event type.
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
 

+ 4 - 1
runtime-modules/storage/src/lib.rs

@@ -7,8 +7,11 @@ pub mod data_object_type_registry;
 
 mod tests;
 
+// The storage working group instance alias.
+pub type StorageWorkingGroupInstance = working_group::Instance2;
+
 // Alias for storage working group
-pub(crate) type StorageWorkingGroup<T> = working_group::Module<T, working_group::Instance2>;
+pub(crate) type StorageWorkingGroup<T> = working_group::Module<T, StorageWorkingGroupInstance>;
 
 // Alias for the member id.
 pub(crate) type MemberId<T> = <T as membership::members::Trait>::MemberId;

+ 0 - 32
runtime-modules/storage/src/tests/data_object_storage_registry.rs

@@ -1,8 +1,6 @@
 #![cfg(test)]
 
 use super::mock::*;
-use crate::StorageWorkingGroup;
-use srml_support::StorageLinkedMap;
 
 #[test]
 fn initial_state() {
@@ -157,33 +155,3 @@ fn test_toggle_ready() {
         );
     });
 }
-
-#[test]
-fn ensure_setting_genesis_storage_working_group_mint_succeeds() {
-    with_default_mock_builder(|| {
-        let mint_id = <StorageWorkingGroup<Test>>::mint();
-
-        assert!(minting::Mints::<Test>::exists(mint_id));
-
-        let mint = <minting::Module<Test>>::mints(mint_id);
-        assert_eq!(mint.capacity(), STORAGE_WORKING_GROUP_MINT_CAPACITY);
-    });
-}
-
-#[test]
-fn ensure_setting_genesis_constraints_succeeds() {
-    with_default_mock_builder(|| {
-        let default_constraint = common::constraints::InputValidationLengthConstraint::new(
-            STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
-            STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
-        );
-        let opening_text_constraint = <StorageWorkingGroup<Test>>::opening_human_readable_text();
-        let worker_text_constraint =
-            <StorageWorkingGroup<Test>>::worker_application_human_readable_text();
-        let worker_exit_text_constraint = <StorageWorkingGroup<Test>>::worker_exit_rationale_text();
-
-        assert_eq!(opening_text_constraint, default_constraint);
-        assert_eq!(worker_text_constraint, default_constraint);
-        assert_eq!(worker_exit_text_constraint, default_constraint);
-    });
-}

+ 5 - 24
runtime-modules/storage/src/tests/mock.rs

@@ -1,7 +1,6 @@
 #![cfg(test)]
 
 pub use crate::{data_directory, data_object_storage_registry, data_object_type_registry};
-use common::constraints::InputValidationLengthConstraint;
 pub use common::currency::GovernanceCurrency;
 use membership::members;
 pub use system;
@@ -16,11 +15,12 @@ pub use sr_primitives::{
 
 use crate::data_directory::ContentIdExists;
 use crate::data_object_type_registry::IsActiveDataObjectType;
+pub use crate::StorageWorkingGroupInstance;
 use srml_support::{impl_outer_event, impl_outer_origin, parameter_types, StorageLinkedMap};
 
 mod working_group_mod {
+    pub use super::StorageWorkingGroupInstance;
     pub use working_group::Event;
-    pub use working_group::Instance2;
 }
 
 impl_outer_origin! {
@@ -34,7 +34,7 @@ impl_outer_event! {
         data_object_storage_registry<T>,
         balances<T>,
         members<T>,
-        working_group_mod Instance2 <T>,
+        working_group_mod StorageWorkingGroupInstance <T>,
     }
 }
 
@@ -146,7 +146,7 @@ impl GovernanceCurrency for Test {
     type Currency = balances::Module<Self>;
 }
 
-impl working_group::Trait<working_group::Instance2> for Test {
+impl working_group::Trait<StorageWorkingGroupInstance> for Test {
     type Event = MetaEvent;
 }
 
@@ -220,16 +220,11 @@ impl hiring::Trait for Test {
 
 pub struct ExtBuilder {
     first_data_object_type_id: u64,
-    storage_working_group_mint_capacity: u64,
     first_content_id: u64,
     first_relationship_id: u64,
     first_metadata_id: u64,
 }
 
-pub(crate) const STORAGE_WORKING_GROUP_MINT_CAPACITY: u64 = 40000;
-pub(crate) const STORAGE_WORKING_GROUP_CONSTRAINT_MIN: u16 = 1;
-pub(crate) const STORAGE_WORKING_GROUP_CONSTRAINT_DIFF: u16 = 40;
-
 impl Default for ExtBuilder {
     fn default() -> Self {
         Self {
@@ -237,7 +232,6 @@ impl Default for ExtBuilder {
             first_content_id: 2,
             first_relationship_id: 3,
             first_metadata_id: 4,
-            storage_working_group_mint_capacity: STORAGE_WORKING_GROUP_MINT_CAPACITY,
         }
     }
 }
@@ -272,19 +266,6 @@ impl ExtBuilder {
 
         data_object_storage_registry::GenesisConfig::<Test> {
             first_relationship_id: self.first_relationship_id,
-            storage_working_group_mint_capacity: self.storage_working_group_mint_capacity,
-            opening_human_readable_text_constraint: InputValidationLengthConstraint::new(
-                STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
-                STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
-            ),
-            worker_application_human_readable_text_constraint: InputValidationLengthConstraint::new(
-                STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
-                STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
-            ),
-            worker_exit_rationale_text_constraint: InputValidationLengthConstraint::new(
-                STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
-                STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
-            ),
         }
         .assimilate_storage(&mut t)
         .unwrap();
@@ -328,7 +309,7 @@ pub(crate) fn hire_storage_provider() -> (u64, u32) {
         role_stake_profile: None,
     };
 
-    <working_group::WorkerById<Test, working_group::Instance2>>::insert(
+    <working_group::WorkerById<Test, StorageWorkingGroupInstance>>::insert(
         storage_provider_id,
         storage_provider,
     );

+ 38 - 0
runtime-modules/working-group/src/lib.rs

@@ -303,6 +303,20 @@ decl_storage! {
         /// Worker exit rationale text length limits.
         pub WorkerExitRationaleText get(worker_exit_rationale_text) : InputValidationLengthConstraint;
     }
+        add_extra_genesis {
+        config(phantom): rstd::marker::PhantomData<I>;
+        config(storage_working_group_mint_capacity): minting::BalanceOf<T>;
+        config(opening_human_readable_text_constraint): InputValidationLengthConstraint;
+        config(worker_application_human_readable_text_constraint): InputValidationLengthConstraint;
+        config(worker_exit_rationale_text_constraint): InputValidationLengthConstraint;
+        build(|config: &GenesisConfig<T, I>| {
+            Module::<T, I>::initialize_working_group(
+                config.opening_human_readable_text_constraint,
+                config.worker_application_human_readable_text_constraint,
+                config.worker_exit_rationale_text_constraint,
+                config.storage_working_group_mint_capacity)
+        });
+    }
 }
 
 decl_module! {
@@ -1247,6 +1261,30 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
             )
             .map_err(|e| e.into())
     }
+
+    fn initialize_working_group(
+        opening_human_readable_text_constraint: InputValidationLengthConstraint,
+        worker_application_human_readable_text_constraint: InputValidationLengthConstraint,
+        worker_exit_rationale_text_constraint: InputValidationLengthConstraint,
+        storage_working_group_mint_capacity: minting::BalanceOf<T>,
+    ) {
+        // Create a mint.
+        let mint_id_result =
+            <minting::Module<T>>::add_mint(storage_working_group_mint_capacity, None);
+
+        if let Ok(mint_id) = mint_id_result {
+            <Mint<T, I>>::put(mint_id);
+        } else {
+            panic!("Failed to create a mint for the storage working group");
+        }
+
+        // Create constraints
+        <OpeningHumanReadableText<I>>::put(opening_human_readable_text_constraint);
+        <WorkerApplicationHumanReadableText<I>>::put(
+            worker_application_human_readable_text_constraint,
+        );
+        <WorkerExitRationaleText<I>>::put(worker_exit_rationale_text_constraint);
+    }
 }
 
 /// Creates default text constraint.

+ 56 - 47
runtime-modules/working-group/src/tests/fixtures.rs

@@ -1,10 +1,12 @@
-use super::mock::{Balances, Membership, System, Test, TestEvent, WorkingGroup1};
+use super::mock::{
+    Balances, Membership, System, Test, TestEvent, TestWorkingGroup, TestWorkingGroupInstance,
+};
 use crate::types::{
     OpeningPolicyCommitment, RewardPolicy, Worker, WorkerApplication, WorkerOpening,
     WorkerRoleStakeProfile,
 };
 use crate::Error;
-use crate::{Instance1, RawEvent};
+use crate::RawEvent;
 use common::constraints::InputValidationLengthConstraint;
 use srml_support::{StorageLinkedMap, StorageValue};
 use std::collections::BTreeSet;
@@ -39,7 +41,7 @@ impl IncreaseWorkerStakeFixture {
         let stake_id = 0;
         let old_stake = <stake::Module<Test>>::stakes(stake_id);
         let old_balance = Balances::free_balance(&self.account_id);
-        let actual_result = WorkingGroup1::increase_worker_stake(
+        let actual_result = TestWorkingGroup::increase_worker_stake(
             self.origin.clone().into(),
             self.worker_id,
             self.balance,
@@ -92,9 +94,9 @@ impl TerminateWorkerRoleFixture {
     }
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
-        <crate::WorkerExitRationaleText<Instance1>>::put(self.constraint.clone());
+        <crate::WorkerExitRationaleText<TestWorkingGroupInstance>>::put(self.constraint.clone());
 
-        let actual_result = WorkingGroup1::terminate_worker_role(
+        let actual_result = TestWorkingGroup::terminate_worker_role(
             self.origin.clone().into(),
             self.worker_id,
             self.text.clone(),
@@ -103,9 +105,9 @@ impl TerminateWorkerRoleFixture {
 
         if actual_result.is_ok() {
             if actual_result.is_ok() {
-                assert!(!<crate::WorkerById<Test, crate::Instance1>>::exists(
-                    self.worker_id
-                ));
+                assert!(
+                    !<crate::WorkerById<Test, TestWorkingGroupInstance>>::exists(self.worker_id)
+                );
             }
         }
     }
@@ -129,7 +131,7 @@ impl LeaveWorkerRoleFixture {
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
         let rationale_text = b"rationale_text".to_vec();
-        let actual_result = WorkingGroup1::leave_worker_role(
+        let actual_result = TestWorkingGroup::leave_worker_role(
             self.origin.clone().into(),
             self.worker_id,
             rationale_text.clone(),
@@ -137,9 +139,7 @@ impl LeaveWorkerRoleFixture {
         assert_eq!(actual_result, expected_result);
 
         if actual_result.is_ok() {
-            assert!(!<crate::WorkerById<Test, crate::Instance1>>::exists(
-                self.worker_id
-            ));
+            assert!(!<crate::WorkerById<Test, TestWorkingGroupInstance>>::exists(self.worker_id));
         }
     }
 }
@@ -164,7 +164,7 @@ impl UpdateWorkerRewardAccountFixture {
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
         assert_eq!(
-            WorkingGroup1::update_worker_reward_account(
+            TestWorkingGroup::update_worker_reward_account(
                 self.origin.clone().into(),
                 self.worker_id,
                 self.new_role_account_id
@@ -193,7 +193,7 @@ impl UpdateWorkerRoleAccountFixture {
     }
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
-        let actual_result = WorkingGroup1::update_worker_role_account(
+        let actual_result = TestWorkingGroup::update_worker_role_account(
             self.origin.clone().into(),
             self.worker_id,
             self.new_role_account_id,
@@ -201,7 +201,7 @@ impl UpdateWorkerRoleAccountFixture {
         assert_eq!(actual_result, expected_result);
 
         if actual_result.is_ok() {
-            let worker = WorkingGroup1::worker_by_id(self.worker_id);
+            let worker = TestWorkingGroup::worker_by_id(self.worker_id);
 
             assert_eq!(worker.role_account, self.new_role_account_id);
         }
@@ -211,16 +211,23 @@ impl UpdateWorkerRoleAccountFixture {
 pub struct UnsetLeadFixture;
 impl UnsetLeadFixture {
     pub fn unset_lead() {
-        assert_eq!(WorkingGroup1::unset_lead(RawOrigin::Root.into()), Ok(()));
+        assert_eq!(TestWorkingGroup::unset_lead(RawOrigin::Root.into()), Ok(()));
     }
 
     pub fn call_and_assert(origin: RawOrigin<u64>, expected_result: Result<(), Error>) {
-        assert_eq!(WorkingGroup1::unset_lead(origin.into()), expected_result);
+        assert_eq!(TestWorkingGroup::unset_lead(origin.into()), expected_result);
     }
 }
 
+pub fn remove_mint() {
+    let mint_id = <crate::Mint<Test, TestWorkingGroupInstance>>::get();
+    <crate::Mint<Test, TestWorkingGroupInstance>>::kill();
+
+    <minting::Module<Test>>::remove_mint(mint_id);
+}
+
 pub fn set_mint_id(mint_id: u64) {
-    <crate::Mint<Test, crate::Instance1>>::put(mint_id);
+    <crate::Mint<Test, TestWorkingGroupInstance>>::put(mint_id);
 }
 
 pub fn create_mint() -> u64 {
@@ -260,8 +267,8 @@ impl FillWorkerOpeningFixture {
     }
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) -> u64 {
-        let saved_worker_next_id = WorkingGroup1::next_worker_id();
-        let actual_result = WorkingGroup1::fill_worker_opening(
+        let saved_worker_next_id = TestWorkingGroup::next_worker_id();
+        let actual_result = TestWorkingGroup::fill_worker_opening(
             self.origin.clone().into(),
             self.opening_id,
             self.successful_worker_application_ids.clone(),
@@ -270,10 +277,10 @@ impl FillWorkerOpeningFixture {
         assert_eq!(actual_result.clone(), expected_result);
 
         if actual_result.is_ok() {
-            assert_eq!(WorkingGroup1::next_worker_id(), saved_worker_next_id + 1);
+            assert_eq!(TestWorkingGroup::next_worker_id(), saved_worker_next_id + 1);
             let worker_id = saved_worker_next_id;
 
-            let opening = WorkingGroup1::worker_opening_by_id(self.opening_id);
+            let opening = TestWorkingGroup::worker_opening_by_id(self.opening_id);
 
             let role_stake_profile = if opening
                 .policy_commitment
@@ -303,7 +310,7 @@ impl FillWorkerOpeningFixture {
                 role_stake_profile,
             };
 
-            let actual_worker = WorkingGroup1::worker_by_id(worker_id);
+            let actual_worker = TestWorkingGroup::worker_by_id(worker_id);
 
             assert_eq!(actual_worker, expected_worker);
         }
@@ -328,7 +335,7 @@ impl BeginReviewWorkerApplicationsFixture {
         BeginReviewWorkerApplicationsFixture { origin, ..self }
     }
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
-        let actual_result = WorkingGroup1::begin_worker_applicant_review(
+        let actual_result = TestWorkingGroup::begin_worker_applicant_review(
             self.origin.clone().into(),
             self.opening_id,
         );
@@ -358,7 +365,7 @@ impl TerminateApplicationFixture {
         }
     }
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
-        let actual_result = WorkingGroup1::terminate_worker_application(
+        let actual_result = TestWorkingGroup::terminate_worker_application(
             self.origin.clone().into(),
             self.worker_application_id,
         );
@@ -387,7 +394,7 @@ impl WithdrawApplicationFixture {
         }
     }
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
-        let actual_result = WorkingGroup1::withdraw_worker_application(
+        let actual_result = TestWorkingGroup::withdraw_worker_application(
             self.origin.clone().into(),
             self.worker_application_id,
         );
@@ -460,13 +467,13 @@ impl ApplyOnWorkerOpeningFixture {
             role_account: 1,
             opt_role_stake_balance: None,
             opt_application_stake_balance: None,
-            human_readable_text: Vec::new(),
+            human_readable_text: b"human_text".to_vec(),
         }
     }
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) -> u64 {
-        let saved_application_next_id = WorkingGroup1::next_worker_application_id();
-        let actual_result = WorkingGroup1::apply_on_worker_opening(
+        let saved_application_next_id = TestWorkingGroup::next_worker_application_id();
+        let actual_result = TestWorkingGroup::apply_on_worker_opening(
             self.origin.clone().into(),
             self.member_id,
             self.worker_opening_id,
@@ -479,12 +486,12 @@ impl ApplyOnWorkerOpeningFixture {
 
         if actual_result.is_ok() {
             assert_eq!(
-                WorkingGroup1::next_worker_application_id(),
+                TestWorkingGroup::next_worker_application_id(),
                 saved_application_next_id + 1
             );
             let application_id = saved_application_next_id;
 
-            let actual_application = WorkingGroup1::worker_application_by_id(application_id);
+            let actual_application = TestWorkingGroup::worker_application_by_id(application_id);
 
             let expected_application = WorkerApplication {
                 role_account: self.role_account,
@@ -495,7 +502,7 @@ impl ApplyOnWorkerOpeningFixture {
 
             assert_eq!(actual_application, expected_application);
 
-            let current_opening = WorkingGroup1::worker_opening_by_id(self.worker_opening_id);
+            let current_opening = TestWorkingGroup::worker_opening_by_id(self.worker_opening_id);
             assert!(current_opening
                 .worker_applications
                 .contains(&application_id));
@@ -519,8 +526,10 @@ impl AcceptWorkerApplicationsFixture {
     }
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) {
-        let actual_result =
-            WorkingGroup1::accept_worker_applications(self.origin.clone().into(), self.opening_id);
+        let actual_result = TestWorkingGroup::accept_worker_applications(
+            self.origin.clone().into(),
+            self.opening_id,
+        );
         assert_eq!(actual_result, expected_result);
     }
 }
@@ -529,7 +538,7 @@ pub struct SetLeadFixture;
 impl SetLeadFixture {
     pub fn set_lead(lead_account_id: u64) {
         assert_eq!(
-            WorkingGroup1::set_lead(RawOrigin::Root.into(), 1, lead_account_id),
+            TestWorkingGroup::set_lead(RawOrigin::Root.into(), 1, lead_account_id),
             Ok(())
         );
     }
@@ -541,7 +550,7 @@ impl SetLeadFixture {
         expected_result: Result<(), Error>,
     ) {
         assert_eq!(
-            WorkingGroup1::set_lead(origin.into(), member_id, account_id),
+            TestWorkingGroup::set_lead(origin.into(), member_id, account_id),
             expected_result
         );
     }
@@ -560,7 +569,7 @@ impl Default for AddWorkerOpeningFixture {
             origin: RawOrigin::Signed(1),
             activate_at: hiring::ActivateOpeningAt::CurrentBlock,
             commitment: <OpeningPolicyCommitment<u64, u64>>::default(),
-            human_readable_text: Vec::new(),
+            human_readable_text: b"human_text".to_vec(),
         }
     }
 }
@@ -577,8 +586,8 @@ impl AddWorkerOpeningFixture {
     }
 
     pub fn call_and_assert(&self, expected_result: Result<(), Error>) -> u64 {
-        let saved_opening_next_id = WorkingGroup1::next_worker_opening_id();
-        let actual_result = WorkingGroup1::add_worker_opening(
+        let saved_opening_next_id = TestWorkingGroup::next_worker_opening_id();
+        let actual_result = TestWorkingGroup::add_worker_opening(
             self.origin.clone().into(),
             self.activate_at.clone(),
             self.commitment.clone(),
@@ -588,12 +597,12 @@ impl AddWorkerOpeningFixture {
 
         if actual_result.is_ok() {
             assert_eq!(
-                WorkingGroup1::next_worker_opening_id(),
+                TestWorkingGroup::next_worker_opening_id(),
                 saved_opening_next_id + 1
             );
             let opening_id = saved_opening_next_id;
 
-            let actual_opening = WorkingGroup1::worker_opening_by_id(opening_id);
+            let actual_opening = TestWorkingGroup::worker_opening_by_id(opening_id);
 
             let expected_opening = WorkerOpening::<u64, u64, u64, u64> {
                 opening_id,
@@ -637,13 +646,13 @@ impl EventFixture {
                 Vec<u8>,
                 u64,
                 u64,
-                crate::Instance1,
+                TestWorkingGroupInstance,
             >,
         >,
     ) {
         let converted_events = expected_raw_events
             .iter()
-            .map(|ev| TestEvent::working_group_Instance1(ev.clone()))
+            .map(|ev| TestEvent::working_group_TestWorkingGroupInstance(ev.clone()))
             .collect::<Vec<TestEvent>>();
 
         Self::assert_global_events(converted_events)
@@ -673,10 +682,10 @@ impl EventFixture {
             Vec<u8>,
             u64,
             u64,
-            crate::Instance1,
+            TestWorkingGroupInstance,
         >,
     ) {
-        let converted_event = TestEvent::working_group_Instance1(expected_raw_event);
+        let converted_event = TestEvent::working_group_TestWorkingGroupInstance(expected_raw_event);
 
         Self::assert_last_global_event(converted_event)
     }
@@ -721,7 +730,7 @@ impl DecreaseWorkerStakeFixture {
         let stake_id = 0;
         let old_balance = Balances::free_balance(&self.account_id);
         let old_stake = <stake::Module<Test>>::stakes(stake_id);
-        let actual_result = WorkingGroup1::decrease_worker_stake(
+        let actual_result = TestWorkingGroup::decrease_worker_stake(
             self.origin.clone().into(),
             self.worker_id,
             self.balance,
@@ -783,7 +792,7 @@ impl SlashWorkerStakeFixture {
         let stake_id = 0;
         let old_balance = Balances::free_balance(&self.account_id);
         let old_stake = <stake::Module<Test>>::stakes(stake_id);
-        let actual_result = WorkingGroup1::slash_worker_stake(
+        let actual_result = TestWorkingGroup::slash_worker_stake(
             self.origin.clone().into(),
             self.worker_id,
             self.balance,

+ 32 - 7
runtime-modules/working-group/src/tests/mock.rs

@@ -1,3 +1,5 @@
+use crate::{Module, Trait};
+use common::constraints::InputValidationLengthConstraint;
 use primitives::H256;
 use sr_primitives::{
     testing::Header,
@@ -6,15 +8,13 @@ use sr_primitives::{
 };
 use srml_support::{impl_outer_event, impl_outer_origin, parameter_types};
 
-use crate::{Instance1, Module, Trait};
-
 impl_outer_origin! {
         pub enum Origin for Test {}
 }
 
 mod working_group {
+    pub use super::TestWorkingGroupInstance;
     pub use crate::Event;
-    pub use crate::Instance1;
 }
 
 mod membership_mod {
@@ -24,7 +24,7 @@ mod membership_mod {
 impl_outer_event! {
     pub enum TestEvent for Test {
         balances<T>,
-        working_group Instance1 <T>,
+        working_group TestWorkingGroupInstance <T>,
         membership_mod<T>,
     }
 }
@@ -124,17 +124,42 @@ impl recurringrewards::Trait for Test {
 pub type Balances = balances::Module<Test>;
 pub type System = system::Module<Test>;
 
-impl Trait<Instance1> for Test {
+impl Trait<TestWorkingGroupInstance> for Test {
     type Event = TestEvent;
 }
 
 pub type Membership = membership::members::Module<Test>;
-pub type WorkingGroup1 = Module<Test, Instance1>;
+
+pub type TestWorkingGroupInstance = crate::Instance1;
+pub type TestWorkingGroup = Module<Test, TestWorkingGroupInstance>;
+
+pub(crate) const STORAGE_WORKING_GROUP_MINT_CAPACITY: u64 = 40000;
+pub(crate) const STORAGE_WORKING_GROUP_CONSTRAINT_MIN: u16 = 1;
+pub(crate) const STORAGE_WORKING_GROUP_CONSTRAINT_DIFF: u16 = 40;
 
 pub fn build_test_externalities() -> runtime_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let mut t = system::GenesisConfig::default()
         .build_storage::<Test>()
         .unwrap();
 
+    crate::GenesisConfig::<Test, TestWorkingGroupInstance> {
+        phantom: Default::default(),
+        storage_working_group_mint_capacity: STORAGE_WORKING_GROUP_MINT_CAPACITY,
+        opening_human_readable_text_constraint: InputValidationLengthConstraint::new(
+            STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
+            STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
+        ),
+        worker_application_human_readable_text_constraint: InputValidationLengthConstraint::new(
+            STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
+            STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
+        ),
+        worker_exit_rationale_text_constraint: InputValidationLengthConstraint::new(
+            STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
+            STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
+        ),
+    }
+    .assimilate_storage(&mut t)
+    .unwrap();
+
     t.into()
 }

+ 92 - 38
runtime-modules/working-group/src/tests/mod.rs

@@ -1,11 +1,14 @@
 mod fixtures;
 mod mock;
 
-use crate::tests::mock::Test;
 use crate::types::{OpeningPolicyCommitment, RewardPolicy};
-use crate::{Error, Instance1, Lead, RawEvent};
+use crate::{Error, Lead, RawEvent};
 use common::constraints::InputValidationLengthConstraint;
-use mock::{build_test_externalities, TestEvent, WorkingGroup1};
+use mock::{
+    build_test_externalities, Test, TestEvent, TestWorkingGroup, TestWorkingGroupInstance,
+    STORAGE_WORKING_GROUP_CONSTRAINT_DIFF, STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
+    STORAGE_WORKING_GROUP_MINT_CAPACITY,
+};
 use srml_support::{StorageLinkedMap, StorageValue};
 use std::collections::BTreeMap;
 use system::RawOrigin;
@@ -16,14 +19,14 @@ use fixtures::*;
 fn set_lead_succeeds() {
     build_test_externalities().execute_with(|| {
         // Ensure that lead is default
-        assert_eq!(WorkingGroup1::current_lead(), None);
+        assert_eq!(TestWorkingGroup::current_lead(), None);
 
         let lead_account_id = 1;
         let lead_member_id = 1;
 
         // Set lead
         assert_eq!(
-            WorkingGroup1::set_lead(RawOrigin::Root.into(), lead_member_id, lead_account_id),
+            TestWorkingGroup::set_lead(RawOrigin::Root.into(), lead_member_id, lead_account_id),
             Ok(())
         );
 
@@ -31,7 +34,7 @@ fn set_lead_succeeds() {
             member_id: lead_member_id,
             role_account_id: lead_account_id,
         };
-        assert_eq!(WorkingGroup1::current_lead(), Some(lead));
+        assert_eq!(TestWorkingGroup::current_lead(), Some(lead));
 
         EventFixture::assert_crate_events(vec![RawEvent::LeaderSet(
             lead_member_id,
@@ -71,10 +74,12 @@ fn add_worker_opening_fails_with_invalid_human_readable_text() {
     build_test_externalities().execute_with(|| {
         SetLeadFixture::set_lead(1);
 
-        <crate::OpeningHumanReadableText<Instance1>>::put(InputValidationLengthConstraint {
-            min: 1,
-            max_min_diff: 5,
-        });
+        <crate::OpeningHumanReadableText<TestWorkingGroupInstance>>::put(
+            InputValidationLengthConstraint {
+                min: 1,
+                max_min_diff: 5,
+            },
+        );
 
         let add_worker_opening_fixture = AddWorkerOpeningFixture::default().with_text(Vec::new());
 
@@ -190,11 +195,18 @@ fn apply_on_worker_opening_succeeds() {
         appy_on_worker_opening_fixture.call_and_assert(Ok(()));
 
         EventFixture::assert_global_events(vec![
-            TestEvent::working_group_Instance1(RawEvent::LeaderSet(1, lead_account_id)),
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::LeaderSet(
+                1,
+                lead_account_id,
+            )),
             TestEvent::membership_mod(membership::members::RawEvent::MemberRegistered(0, 0)),
             TestEvent::membership_mod(membership::members::RawEvent::MemberRegistered(1, 1)),
-            TestEvent::working_group_Instance1(RawEvent::WorkerOpeningAdded(opening_id)),
-            TestEvent::working_group_Instance1(RawEvent::AppliedOnWorkerOpening(opening_id, 0)),
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::WorkerOpeningAdded(
+                opening_id,
+            )),
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::AppliedOnWorkerOpening(
+                opening_id, 0,
+            )),
         ]);
     });
 }
@@ -308,7 +320,7 @@ fn apply_on_worker_opening_fails_with_invalid_text() {
 
         let opening_id = 0; // newly created opening
 
-        <crate::WorkerApplicationHumanReadableText<Instance1>>::put(
+        <crate::WorkerApplicationHumanReadableText<TestWorkingGroupInstance>>::put(
             InputValidationLengthConstraint {
                 min: 1,
                 max_min_diff: 5,
@@ -374,17 +386,22 @@ fn withdraw_worker_application_succeeds() {
         withdraw_application_fixture.call_and_assert(Ok(()));
 
         EventFixture::assert_global_events(vec![
-            TestEvent::working_group_Instance1(RawEvent::LeaderSet(1, lead_account_id)),
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::LeaderSet(
+                1,
+                lead_account_id,
+            )),
             TestEvent::membership_mod(membership::members::RawEvent::MemberRegistered(0, 0)),
             TestEvent::membership_mod(membership::members::RawEvent::MemberRegistered(1, 1)),
-            TestEvent::working_group_Instance1(RawEvent::WorkerOpeningAdded(opening_id)),
-            TestEvent::working_group_Instance1(RawEvent::AppliedOnWorkerOpening(
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::WorkerOpeningAdded(
                 opening_id,
-                application_id,
             )),
-            TestEvent::working_group_Instance1(RawEvent::WorkerApplicationWithdrawn(
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::AppliedOnWorkerOpening(
+                opening_id,
                 application_id,
             )),
+            TestEvent::working_group_TestWorkingGroupInstance(
+                RawEvent::WorkerApplicationWithdrawn(application_id),
+            ),
         ]);
     });
 }
@@ -503,17 +520,22 @@ fn terminate_worker_application_succeeds() {
         terminate_application_fixture.call_and_assert(Ok(()));
 
         EventFixture::assert_global_events(vec![
-            TestEvent::working_group_Instance1(RawEvent::LeaderSet(1, lead_account_id)),
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::LeaderSet(
+                1,
+                lead_account_id,
+            )),
             TestEvent::membership_mod(membership::members::RawEvent::MemberRegistered(0, 0)),
             TestEvent::membership_mod(membership::members::RawEvent::MemberRegistered(1, 1)),
-            TestEvent::working_group_Instance1(RawEvent::WorkerOpeningAdded(opening_id)),
-            TestEvent::working_group_Instance1(RawEvent::AppliedOnWorkerOpening(
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::WorkerOpeningAdded(
                 opening_id,
-                application_id,
             )),
-            TestEvent::working_group_Instance1(RawEvent::WorkerApplicationTerminated(
+            TestEvent::working_group_TestWorkingGroupInstance(RawEvent::AppliedOnWorkerOpening(
+                opening_id,
                 application_id,
             )),
+            TestEvent::working_group_TestWorkingGroupInstance(
+                RawEvent::WorkerApplicationTerminated(application_id),
+            ),
         ]);
     });
 }
@@ -899,6 +921,7 @@ fn fill_worker_opening_fails_with_invalid_reward_policy() {
                     payout_interval: None,
                 });
 
+        remove_mint(); //removes default mintx
         fill_worker_opening_fixture.call_and_assert(Err(Error::FillWorkerOpeningMintDoesNotExist));
 
         set_mint_id(22);
@@ -927,11 +950,11 @@ fn unset_lead_succeeds() {
             member_id: lead_member_id,
             role_account_id: lead_account_id,
         };
-        assert_eq!(WorkingGroup1::current_lead(), Some(lead));
+        assert_eq!(TestWorkingGroup::current_lead(), Some(lead));
 
         UnsetLeadFixture::unset_lead();
 
-        assert_eq!(WorkingGroup1::current_lead(), None);
+        assert_eq!(TestWorkingGroup::current_lead(), None);
 
         EventFixture::assert_crate_events(vec![
             RawEvent::LeaderSet(lead_member_id, lead_account_id),
@@ -1199,10 +1222,10 @@ fn leave_worker_role_fails_with_invalid_recurring_reward_relationships() {
     build_test_externalities().execute_with(|| {
         let worker_id = fill_default_worker_position();
 
-        let mut worker = WorkingGroup1::worker_by_id(worker_id);
+        let mut worker = TestWorkingGroup::worker_by_id(worker_id);
         worker.reward_relationship = Some(2);
 
-        <crate::WorkerById<Test, crate::Instance1>>::insert(worker_id, worker);
+        <crate::WorkerById<Test, TestWorkingGroupInstance>>::insert(worker_id, worker);
 
         let leave_worker_role_fixture = LeaveWorkerRoleFixture::default_for_worker_id(worker_id);
 
@@ -1531,7 +1554,7 @@ fn slash_worker_stake_fails_with_not_set_lead() {
 #[test]
 fn get_all_worker_ids_succeeds() {
     build_test_externalities().execute_with(|| {
-        let worker_ids = WorkingGroup1::get_all_worker_ids();
+        let worker_ids = TestWorkingGroup::get_all_worker_ids();
         assert_eq!(worker_ids, Vec::new());
 
         let worker_id1 = fill_worker_position(None, None, true);
@@ -1540,12 +1563,12 @@ fn get_all_worker_ids_succeeds() {
         let mut expected_ids = vec![worker_id1, worker_id2];
         expected_ids.sort();
 
-        let mut worker_ids = WorkingGroup1::get_all_worker_ids();
+        let mut worker_ids = TestWorkingGroup::get_all_worker_ids();
         worker_ids.sort();
         assert_eq!(worker_ids, expected_ids);
 
-        <crate::WorkerById<Test, crate::Instance1>>::remove(worker_id1);
-        let worker_ids = WorkingGroup1::get_all_worker_ids();
+        <crate::WorkerById<Test, TestWorkingGroupInstance>>::remove(worker_id1);
+        let worker_ids = TestWorkingGroup::get_all_worker_ids();
         assert_eq!(worker_ids, vec![worker_id2]);
     });
 }
@@ -1554,10 +1577,10 @@ fn get_all_worker_ids_succeeds() {
 fn set_working_group_mint_capacity_succeeds() {
     build_test_externalities().execute_with(|| {
         let mint_id = <minting::Module<Test>>::add_mint(0, None).unwrap();
-        <crate::Mint<Test, crate::Instance1>>::put(mint_id);
+        <crate::Mint<Test, TestWorkingGroupInstance>>::put(mint_id);
 
         let capacity = 15000;
-        let result = WorkingGroup1::set_mint_capacity(RawOrigin::Root.into(), capacity);
+        let result = TestWorkingGroup::set_mint_capacity(RawOrigin::Root.into(), capacity);
 
         assert_eq!(result, Ok(()));
 
@@ -1569,8 +1592,10 @@ fn set_working_group_mint_capacity_succeeds() {
 #[test]
 fn set_working_group_mint_capacity_fails_with_not_set_working_group_mint() {
     build_test_externalities().execute_with(|| {
+        remove_mint(); //removes default mint
+
         let capacity = 15000;
-        let result = WorkingGroup1::set_mint_capacity(RawOrigin::Root.into(), capacity);
+        let result = TestWorkingGroup::set_mint_capacity(RawOrigin::Root.into(), capacity);
 
         assert_eq!(result, Err(Error::WorkingGroupMintIsNotSet));
     });
@@ -1581,8 +1606,8 @@ fn set_working_group_mint_capacity_fails_with_mint_not_found() {
     build_test_externalities().execute_with(|| {
         let capacity = 15000;
 
-        <crate::Mint<Test, Instance1>>::put(5); // random mint id
-        let result = WorkingGroup1::set_mint_capacity(RawOrigin::Root.into(), capacity);
+        <crate::Mint<Test, TestWorkingGroupInstance>>::put(5); // random mint id
+        let result = TestWorkingGroup::set_mint_capacity(RawOrigin::Root.into(), capacity);
 
         assert_eq!(result, Err(Error::CannotFindMint));
     });
@@ -1592,8 +1617,37 @@ fn set_working_group_mint_capacity_fails_with_mint_not_found() {
 fn set_working_group_mint_capacity_fails_with_invalid_origin() {
     build_test_externalities().execute_with(|| {
         let capacity = 15000;
-        let result = WorkingGroup1::set_mint_capacity(RawOrigin::None.into(), capacity);
+        let result = TestWorkingGroup::set_mint_capacity(RawOrigin::None.into(), capacity);
 
         assert_eq!(result, Err(Error::RequireRootOrigin));
     });
 }
+
+#[test]
+fn ensure_setting_genesis_storage_working_group_mint_succeeds() {
+    build_test_externalities().execute_with(|| {
+        let mint_id = TestWorkingGroup::mint();
+
+        assert!(minting::Mints::<Test>::exists(mint_id));
+
+        let mint = <minting::Module<Test>>::mints(mint_id);
+        assert_eq!(mint.capacity(), STORAGE_WORKING_GROUP_MINT_CAPACITY);
+    });
+}
+
+#[test]
+fn ensure_setting_genesis_constraints_succeeds() {
+    build_test_externalities().execute_with(|| {
+        let default_constraint = common::constraints::InputValidationLengthConstraint::new(
+            STORAGE_WORKING_GROUP_CONSTRAINT_MIN,
+            STORAGE_WORKING_GROUP_CONSTRAINT_DIFF,
+        );
+        let opening_text_constraint = TestWorkingGroup::opening_human_readable_text();
+        let worker_text_constraint = TestWorkingGroup::worker_application_human_readable_text();
+        let worker_exit_text_constraint = TestWorkingGroup::worker_exit_rationale_text();
+
+        assert_eq!(opening_text_constraint, default_constraint);
+        assert_eq!(worker_text_constraint, default_constraint);
+        assert_eq!(worker_exit_text_constraint, default_constraint);
+    });
+}

+ 4 - 3
runtime/src/lib.rs

@@ -755,9 +755,10 @@ impl forum::Trait for Runtime {
 impl migration::Trait for Runtime {
     type Event = Event;
 }
+// The storage working group instance alias.
+pub type StorageWorkingGroupInstance = working_group::Instance2;
 
-// Storage working group
-impl working_group::Trait<working_group::Instance2> for Runtime {
+impl working_group::Trait<StorageWorkingGroupInstance> for Runtime {
     type Event = Event;
 }
 
@@ -871,7 +872,7 @@ construct_runtime!(
         ProposalsCodex: proposals_codex::{Module, Call, Storage, Error, Config<T>},
         // --- Working groups
         // reserved for the future use: ForumWorkingGroup: working_group::<Instance1>::{Module, Call, Storage, Event<T>},
-        StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Event<T>},
+        StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Config<T>, Error, Event<T>},
     }
 );
 

+ 6 - 7
runtime/src/migration.rs

@@ -25,10 +25,7 @@ impl<T: Trait> Module<T> {
         Self::initialize_storage_working_group_mint();
         Self::initialize_storage_working_group_text_constraints();
 
-        // ** Order is important!
-        Self::clear_storage_data_object_registry_data();
-        Self::clear_storage_data_directory_data();
-        // **
+        Self::clear_storage_data();
     }
 }
 
@@ -104,7 +101,8 @@ impl<T: Trait> Module<T> {
         );
     }
 
-    fn clear_storage_data_object_registry_data() {
+    fn clear_storage_data() {
+        // Clear storage data object registry data.
         for id in <storage::data_directory::Module<T>>::known_content_ids() {
             <storage::data_object_storage_registry::RelationshipsByContentId<T>>::remove(id);
         }
@@ -117,9 +115,10 @@ impl<T: Trait> Module<T> {
 
             potential_id += <T as storage::data_object_storage_registry::Trait>::DataObjectStorageRelationshipId::one();
         }
-    }
 
-    fn clear_storage_data_directory_data() {
+        storage::data_object_storage_registry::NextRelationshipId::<T>::put(<T as storage::data_object_storage_registry::Trait>::DataObjectStorageRelationshipId::one());
+
+        // Clear storage data directory data.
         for id in <storage::data_directory::Module<T>>::known_content_ids() {
             <storage::data_directory::DataObjectByContentId<T>>::remove(id);
         }