فهرست منبع

Add bureacracy dependency and fix tests in the storage module

Shamil Gadelshin 4 سال پیش
والد
کامیت
c4da5f18d8

+ 7 - 2
Cargo.lock

@@ -1614,7 +1614,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node-runtime"
-version = "6.14.0"
+version = "6.15.0"
 dependencies = [
  "parity-scale-codec",
  "safe-mix",
@@ -5443,7 +5443,7 @@ dependencies = [
 
 [[package]]
 name = "substrate-storage-module"
-version = "1.0.0"
+version = "1.1.0"
 dependencies = [
  "parity-scale-codec",
  "serde",
@@ -5454,10 +5454,15 @@ dependencies = [
  "srml-support",
  "srml-system",
  "srml-timestamp",
+ "substrate-bureaucracy-module",
  "substrate-common-module",
+ "substrate-hiring-module",
  "substrate-membership-module",
  "substrate-primitives",
+ "substrate-recurring-reward-module",
  "substrate-roles-module",
+ "substrate-stake-module",
+ "substrate-token-mint-module",
 ]
 
 [[package]]

+ 28 - 2
runtime-modules/storage/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = 'substrate-storage-module'
-version = '1.0.0'
+version = '1.1.0'
 authors = ['Joystream contributors']
 edition = '2018'
 
@@ -18,6 +18,7 @@ std = [
 	'common/std',
 	'membership/std',
 	'roles/std',
+	'bureaucracy/std',
 ]
 
 
@@ -83,6 +84,11 @@ default_features = false
 package = 'substrate-roles-module'
 path = '../roles'
 
+[dependencies.bureaucracy]
+default_features = false
+package = 'substrate-bureaucracy-module'
+path = '../bureaucracy'
+
 [dev-dependencies.runtime-io]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
@@ -93,4 +99,24 @@ rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-balances'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
+rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
+
+[dev-dependencies.recurringrewards]
+default_features = false
+package = 'substrate-recurring-reward-module'
+path = '../recurring-reward'
+
+[dev-dependencies.hiring]
+default_features = false
+package = 'substrate-hiring-module'
+path = '../hiring'
+
+[dev-dependencies.stake]
+default_features = false
+package = 'substrate-stake-module'
+path = '../stake'
+
+[dev-dependencies.minting]
+default_features = false
+package = 'substrate-token-mint-module'
+path = '../token-minting'

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

@@ -1,6 +1,7 @@
 // Clippy linter requirement
-#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
-                                          // example:  pub NextRelationshipId get(next_relationship_id) build(|config: &GenesisConfig<T>|
+// disable it because of the substrate lib design
+// example:  pub NextRelationshipId get(next_relationship_id) build(|config: &GenesisConfig<T>|
+#![allow(clippy::redundant_closure_call)]
 
 use crate::data_directory::Trait as DDTrait;
 use crate::traits::{ContentHasStorage, ContentIdExists};

+ 4 - 3
runtime-modules/storage/src/data_object_type_registry.rs

@@ -1,6 +1,7 @@
 // Clippy linter requirement
-#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
-                                          // example:   NextDataObjectTypeId get(next_data_object_type_id) build(|config: &GenesisConfig<T>|
+// disable it because of the substrate lib design
+// example:   NextDataObjectTypeId get(next_data_object_type_id) build(|config: &GenesisConfig<T>|
+#![allow(clippy::redundant_closure_call)]
 
 use crate::traits;
 use codec::{Codec, Decode, Encode};
@@ -9,7 +10,7 @@ use sr_primitives::traits::{MaybeSerialize, Member, SimpleArithmetic};
 use srml_support::{decl_event, decl_module, decl_storage, Parameter};
 use system::ensure_root;
 
-pub trait Trait: system::Trait {
+pub trait Trait: system::Trait + bureaucracy::Trait<bureaucracy::Instance2> {
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
 
     type DataObjectTypeId: Parameter

+ 38 - 1
runtime-modules/storage/src/tests/mock.rs

@@ -17,6 +17,11 @@ pub use sr_primitives::{
 
 use srml_support::{impl_outer_event, impl_outer_origin, parameter_types};
 
+mod bureaucracy_mod {
+    pub use bureaucracy::Event;
+    pub use bureaucracy::Instance2;
+}
+
 impl_outer_origin! {
     pub enum Origin for Test {}
 }
@@ -29,6 +34,7 @@ impl_outer_event! {
         actors<T>,
         balances<T>,
         members<T>,
+        bureaucracy_mod Instance2 <T>,
     }
 }
 
@@ -139,6 +145,7 @@ parameter_types! {
     pub const TransactionBaseFee: u32 = 1;
     pub const TransactionByteFee: u32 = 0;
     pub const InitialMembersBalance: u32 = 2000;
+    pub const StakePoolId: [u8; 8] = *b"joystake";
 }
 
 impl balances::Trait for Test {
@@ -162,6 +169,10 @@ impl GovernanceCurrency for Test {
     type Currency = balances::Module<Self>;
 }
 
+impl bureaucracy::Trait<bureaucracy::Instance2> for Test {
+    type Event = MetaEvent;
+}
+
 impl data_object_type_registry::Trait for Test {
     type Event = MetaEvent;
     type DataObjectTypeId = u64;
@@ -191,6 +202,32 @@ impl members::Trait for Test {
     type InitialMembersBalance = InitialMembersBalance;
 }
 
+impl stake::Trait for Test {
+    type Currency = Balances;
+    type StakePoolId = StakePoolId;
+    type StakingEventsHandler = ();
+    type StakeId = u64;
+    type SlashId = u64;
+}
+
+impl minting::Trait for Test {
+    type Currency = Balances;
+    type MintId = u64;
+}
+
+impl recurringrewards::Trait for Test {
+    type PayoutStatusHandler = ();
+    type RecipientId = u64;
+    type RewardRelationshipId = u64;
+}
+
+impl hiring::Trait for Test {
+    type OpeningId = u64;
+    type ApplicationId = u64;
+    type ApplicationDeactivatedHandler = ();
+    type StakeHandlerProvider = hiring::Module<Self>;
+}
+
 impl actors::Trait for Test {
     type Event = MetaEvent;
     type OnActorRemoved = ();
@@ -263,11 +300,11 @@ impl ExtBuilder {
     }
 }
 
+pub type Balances = balances::Module<Test>;
 pub type System = system::Module<Test>;
 pub type TestDataObjectTypeRegistry = data_object_type_registry::Module<Test>;
 pub type TestDataObjectType = data_object_type_registry::DataObjectType;
 pub type TestDataDirectory = data_directory::Module<Test>;
-// pub type TestDataObject = data_directory::DataObject<Test>;
 pub type TestDataObjectStorageRegistry = data_object_storage_registry::Module<Test>;
 pub type TestActors = actors::Module<Test>;
 

+ 1 - 1
runtime/Cargo.toml

@@ -5,7 +5,7 @@ edition = '2018'
 name = 'joystream-node-runtime'
 # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1
 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion
-version = '6.14.0'
+version = '6.15.0'
 
 [features]
 default = ['std']

+ 8 - 2
runtime/src/lib.rs

@@ -142,7 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
     spec_name: create_runtime_str!("joystream-node"),
     impl_name: create_runtime_str!("joystream-node"),
     authoring_version: 6,
-    spec_version: 14,
+    spec_version: 15,
     impl_version: 0,
     apis: RUNTIME_API_VERSIONS,
 };
@@ -814,6 +814,11 @@ impl bureaucracy::Trait<bureaucracy::Instance1> for Runtime {
     type Event = Event;
 }
 
+// Storage working group bureaucracy
+impl bureaucracy::Trait<bureaucracy::Instance2> for Runtime {
+    type Event = Event;
+}
+
 impl actors::Trait for Runtime {
     type Event = Event;
     type OnActorRemoved = HandleActorRemoved;
@@ -935,8 +940,9 @@ construct_runtime!(
         ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
         ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
         ProposalsCodex: proposals_codex::{Module, Call, Storage, Error, Config<T>},
-        // ---
+        // --- Bureaucracy
         ForumBureaucracy: bureaucracy::<Instance1>::{Module, Call, Storage, Event<T>},
+        StorageBureaucracy: bureaucracy::<Instance2>::{Module, Call, Storage, Event<T>},
     }
 );