Browse Source

runtime: Remove dependency between membership and working-group.

Shamil Gadelshin 4 years ago
parent
commit
bd91a10996

+ 1 - 0
Cargo.lock

@@ -4279,6 +4279,7 @@ dependencies = [
  "frame-system",
  "pallet-balances",
  "pallet-common",
+ "pallet-membership",
  "pallet-timestamp",
  "parity-scale-codec",
  "serde",

+ 1 - 2
runtime-modules/membership/Cargo.toml

@@ -15,12 +15,12 @@ sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://
 pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
-working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
 
 [dev-dependencies]
 sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 staking-handler = { package = 'staking-handler', default-features = false, path = '../staking-handler'}
+working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
 
 [features]
 default = ['std']
@@ -35,5 +35,4 @@ std = [
 	'pallet-timestamp/std',
 	'balances/std',
 	'common/std',
-	'working-group/std',
 ]

+ 0 - 3
runtime-modules/membership/src/lib.rs

@@ -14,9 +14,6 @@ use sp_std::vec::Vec;
 
 use common::working_group::WorkingGroupIntegration;
 
-// The membership working group instance alias.
-pub type MembershipWorkingGroupInstance = working_group::Instance4;
-
 // Balance type alias
 type BalanceOf<T> = <T as balances::Trait>::Balance;
 

+ 4 - 0
runtime-modules/membership/src/tests/mock.rs

@@ -16,6 +16,10 @@ use sp_runtime::{
     DispatchError, DispatchResult, Perbill,
 };
 
+type MembershipWorkingGroupInstance = working_group::Instance4;
+
+pub use common::currency::GovernanceCurrency;
+
 impl_outer_origin! {
     pub enum Origin for Test {}
 }

+ 9 - 2
runtime-modules/working-group/Cargo.toml

@@ -14,9 +14,13 @@ sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'ht
 sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true}
 staking-handler = { package = 'staking-handler', default-features = false, path = '../staking-handler'}
 
+# Benchmarking
+frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true}
+membership = { package = 'pallet-membership', default-features = false, path = '../membership', optional = true}
+
+
 [dev-dependencies]
 sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
@@ -24,7 +28,10 @@ pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git
 
 [features]
 default = ['std']
-runtime-benchmarks = ["frame-benchmarking"]
+runtime-benchmarks = [
+	"frame-benchmarking",
+	"membership"
+]
 std = [
 	'serde',
 	'codec/std',

+ 7 - 3
runtime-modules/working-group/src/benchmarking.rs

@@ -109,7 +109,7 @@ fn apply_on_opening_helper<T: Trait<I>, I: Instance>(
     application_id
 }
 
-fn add_opening_and_apply_with_multiple_ids<T: Trait<I>, I: Instance>(
+fn add_opening_and_apply_with_multiple_ids<T: Trait<I> + membership::Trait, I: Instance>(
     ids: &Vec<u32>,
     add_opening_origin: &T::Origin,
     staking_role: &StakingRole,
@@ -174,7 +174,7 @@ fn handle_from_id<T: membership::Trait>(id: u32) -> Vec<u8> {
     handle
 }
 
-fn member_funded_account<T: Trait<I>, I: Instance>(
+fn member_funded_account<T: Trait<I> + membership::Trait, I: Instance>(
     name: &'static str,
     id: u32,
 ) -> (T::AccountId, T::MemberId) {
@@ -204,7 +204,7 @@ fn force_missed_reward<T: Trait<I>, I: Instance>() {
     WorkingGroup::<T, _>::on_initialize(curr_block_number);
 }
 
-fn insert_a_worker<T: Trait<I>, I: Instance>(
+fn insert_a_worker<T: Trait<I> + membership::Trait, I: Instance>(
     staking_role: StakingRole,
     job_opening_type: OpeningType,
     id: u32,
@@ -250,6 +250,10 @@ where
 }
 
 benchmarks_instance! {
+    where_clause {
+        where T: membership::Trait
+    }
+
     _ { }
 
     on_initialize_leaving {

+ 1 - 1
runtime/src/lib.rs

@@ -602,7 +602,7 @@ pub type StorageWorkingGroupInstance = storage::StorageWorkingGroupInstance;
 pub type ContentDirectoryWorkingGroupInstance = working_group::Instance3;
 
 // The membership working group instance alias.
-pub type MembershipWorkingGroupInstance = membership::MembershipWorkingGroupInstance;
+pub type MembershipWorkingGroupInstance = working_group::Instance4;
 
 parameter_types! {
     pub const MaxWorkerNumberLimit: u32 = 100;