Sfoglia il codice sorgente

runtime: Upgrade forum pallet.

Shamil Gadelshin 4 anni fa
parent
commit
11d0e82ffb

+ 16 - 0
Cargo.lock

@@ -1003,6 +1003,22 @@ dependencies = [
  "sp-runtime",
 ]
 
+[[package]]
+name = "pallet-forum"
+version = "3.0.0"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "pallet-common",
+ "pallet-timestamp",
+ "parity-scale-codec",
+ "serde",
+ "sp-arithmetic",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+]
+
 [[package]]
 name = "pallet-hiring"
 version = "3.0.0"

+ 1 - 1
Cargo.toml

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

+ 16 - 40
runtime-modules/forum/Cargo.toml

@@ -1,56 +1,32 @@
 [package]
-name = 'substrate-forum-module'
-version = '1.2.2'
+name = 'pallet-forum'
+version = '3.0.0'
 authors = ['Joystream contributors']
 edition = '2018'
 
 [dependencies]
-hex-literal = '0.1.0'
-serde = { version = '1.0.101', optional = true}
-serde_derive = { version = '1.0.101', optional = true }
-rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] }
-# https://users.rust-lang.org/t/failure-derive-compilation-error/39062
-quote = '<=1.0.2'
-
-[dependencies.timestamp]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-timestamp'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.runtime-io]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-io'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
+serde = { version = "1.0.101", optional = true, features = ["derive"] }
+codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
+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'}
+timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 [dev-dependencies]
-runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
-
-[dependencies.common]
-default_features = false
-package = 'substrate-common-module'
-path = '../common'
+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'}
 
 [features]
 default = ['std']
 std = [
 	'serde',
-	'serde_derive',
 	'codec/std',
-	'rstd/std',
-	'runtime-io/std',
-	'runtime-primitives/std',
-	'srml-support/std',
+	'frame-support/std',
 	'system/std',
-  	'balances/std',
+	'sp-arithmetic/std',
+	'sp-runtime/std',
 	'timestamp/std',
 	'common/std',
-]
+]

+ 55 - 65
runtime-modules/forum/src/lib.rs

@@ -7,14 +7,16 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 
 #[cfg(feature = "std")]
-use serde_derive::{Deserialize, Serialize};
+use serde::{Deserialize, Serialize};
 
-use rstd::borrow::ToOwned;
-use rstd::prelude::*;
+//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>;
 
 use codec::{Codec, Decode, Encode};
-use runtime_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic};
-use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure, Parameter};
+use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter};
+use sp_arithmetic::traits::{BaseArithmetic, One};
+use sp_runtime::traits::{MaybeSerialize, Member};
 
 mod mock;
 mod tests;
@@ -264,7 +266,7 @@ pub trait Trait: system::Trait + timestamp::Trait + Sized {
     /// Thread Id type
     type ThreadId: Parameter
         + Member
-        + SimpleArithmetic
+        + BaseArithmetic
         + Codec
         + Default
         + Copy
@@ -274,7 +276,7 @@ pub trait Trait: system::Trait + timestamp::Trait + Sized {
     /// Post Id type
     type PostId: Parameter
         + Member
-        + SimpleArithmetic
+        + BaseArithmetic
         + Codec
         + Default
         + Copy
@@ -286,59 +288,39 @@ decl_storage! {
     trait Store for Module<T: Trait> as Forum {
 
         /// Map category identifier to corresponding category.
-        pub CategoryById get(category_by_id) config(): map CategoryId => Category<T::BlockNumber, T::Moment, T::AccountId>;
+        pub CategoryById get(fn category_by_id) config(): map hasher(blake2_128_concat)
+            CategoryId => Category<T::BlockNumber, T::Moment, T::AccountId>;
 
         /// Category identifier value to be used for the next Category created.
-        pub NextCategoryId get(next_category_id) config(): CategoryId;
+        pub NextCategoryId get(fn next_category_id) config(): CategoryId;
 
         /// Map thread identifier to corresponding thread.
-        pub ThreadById get(thread_by_id) config(): map T::ThreadId => Thread<T::BlockNumber, T::Moment, T::AccountId, T::ThreadId>;
+        pub ThreadById get(fn thread_by_id) config(): map hasher(blake2_128_concat)
+            T::ThreadId => Thread<T::BlockNumber, T::Moment, T::AccountId, T::ThreadId>;
 
         /// Thread identifier value to be used for next Thread in threadById.
-        pub NextThreadId get(next_thread_id) config(): T::ThreadId;
+        pub NextThreadId get(fn next_thread_id) config(): T::ThreadId;
 
         /// Map post identifier to corresponding post.
-        pub PostById get(post_by_id) config(): map T::PostId => Post<T::BlockNumber, T::Moment, T::AccountId, T::ThreadId, T::PostId>;
+        pub PostById get(fn post_by_id) config(): map hasher(blake2_128_concat)
+            T::PostId => Post<T::BlockNumber, T::Moment, T::AccountId, T::ThreadId, T::PostId>;
 
         /// Post identifier value to be used for for next post created.
-        pub NextPostId get(next_post_id) config(): T::PostId;
+        pub NextPostId get(fn next_post_id) config(): T::PostId;
 
         /// Account of forum sudo.
-        pub ForumSudo get(forum_sudo) config(): Option<T::AccountId>;
+        pub ForumSudo get(fn forum_sudo) config(): Option<T::AccountId>;
 
         /// Input constraints
         /// These are all forward looking, that is they are enforced on all
         /// future calls.
-        pub CategoryTitleConstraint get(category_title_constraint) config(): InputValidationLengthConstraint;
-        pub CategoryDescriptionConstraint get(category_description_constraint) config(): InputValidationLengthConstraint;
-        pub ThreadTitleConstraint get(thread_title_constraint) config(): InputValidationLengthConstraint;
-        pub PostTextConstraint get(post_text_constraint) config(): InputValidationLengthConstraint;
-        pub ThreadModerationRationaleConstraint get(thread_moderation_rationale_constraint) config(): InputValidationLengthConstraint;
-        pub PostModerationRationaleConstraint get(post_moderation_rationale_constraint) config(): InputValidationLengthConstraint;
+        pub CategoryTitleConstraint get(fn category_title_constraint) config(): InputValidationLengthConstraint;
+        pub CategoryDescriptionConstraint get(fn category_description_constraint) config(): InputValidationLengthConstraint;
+        pub ThreadTitleConstraint get(fn thread_title_constraint) config(): InputValidationLengthConstraint;
+        pub PostTextConstraint get(fn post_text_constraint) config(): InputValidationLengthConstraint;
+        pub ThreadModerationRationaleConstraint get(fn thread_moderation_rationale_constraint) config(): InputValidationLengthConstraint;
+        pub PostModerationRationaleConstraint get(fn post_moderation_rationale_constraint) config(): InputValidationLengthConstraint;
     }
-    /*
-    JUST GIVING UP ON ALL THIS FOR NOW BECAUSE ITS TAKING TOO LONG
-    Review : https://github.com/paritytech/polkadot/blob/620b8610431e7b5fdd71ce3e94c3ee0177406dcc/runtime/src/parachains.rs#L123-L141
-
-    add_extra_genesis {
-
-        // Explain why we need to put this here.
-        config(initial_forum_sudo) : Option<T::AccountId>;
-
-        build(|
-            storage: &mut generator::StorageOverlay,
-            _: &mut generator::ChildrenStorageOverlay,
-            config: &GenesisConfig<T>
-            | {
-
-
-            if let Some(account_id) = &config.initial_forum_sudo {
-                println!("{}: <ForumSudo<T>>::put(account_id)", account_id);
-                <ForumSudo<T> as generator::StorageValue<_>>::put(&account_id, storage);
-            }
-        })
-    }
-    */
 }
 
 decl_event!(
@@ -383,7 +365,8 @@ decl_module! {
         fn deposit_event() = default;
 
         /// Set forum sudo.
-        fn set_forum_sudo(origin, new_forum_sudo: Option<T::AccountId>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn set_forum_sudo(origin, new_forum_sudo: Option<T::AccountId>) -> DispatchResult {
             ensure_root(origin)?;
 
             /*
@@ -408,7 +391,8 @@ decl_module! {
         }
 
         /// Add a new category.
-        fn create_category(origin, parent: Option<CategoryId>, title: Vec<u8>, description: Vec<u8>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn create_category(origin, parent: Option<CategoryId>, title: Vec<u8>, description: Vec<u8>) -> DispatchResult {
 
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
@@ -487,7 +471,8 @@ decl_module! {
         }
 
         /// Update category
-        fn update_category(origin, category_id: CategoryId, new_archival_status: Option<bool>, new_deletion_status: Option<bool>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn update_category(origin, category_id: CategoryId, new_archival_status: Option<bool>, new_deletion_status: Option<bool>) -> DispatchResult {
 
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
@@ -550,7 +535,8 @@ decl_module! {
         }
 
         /// Create new thread in category
-        fn create_thread(origin, category_id: CategoryId, title: Vec<u8>, text: Vec<u8>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn create_thread(origin, category_id: CategoryId, title: Vec<u8>, text: Vec<u8>) -> DispatchResult {
 
             /*
              * Update SPEC with new errors,
@@ -593,7 +579,8 @@ decl_module! {
         }
 
         /// Moderate thread
-        fn moderate_thread(origin, thread_id: T::ThreadId, rationale: Vec<u8>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn moderate_thread(origin, thread_id: T::ThreadId, rationale: Vec<u8>) -> DispatchResult {
 
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
@@ -644,7 +631,8 @@ decl_module! {
         }
 
         /// Edit post text
-        fn add_post(origin, thread_id: T::ThreadId, text: Vec<u8>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn add_post(origin, thread_id: T::ThreadId, text: Vec<u8>) -> DispatchResult {
 
             /*
              * Update SPEC with new errors,
@@ -681,7 +669,8 @@ decl_module! {
         }
 
         /// Edit post text
-        fn edit_post_text(origin, post_id: T::PostId, new_text: Vec<u8>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn edit_post_text(origin, post_id: T::PostId, new_text: Vec<u8>) -> DispatchResult {
 
             /* Edit spec.
               - forum member guard missing
@@ -728,7 +717,8 @@ decl_module! {
         }
 
         /// Moderate post
-        fn moderate_post(origin, post_id: T::PostId, rationale: Vec<u8>) -> dispatch::Result {
+        #[weight = 10_000_000] // TODO: adjust weight
+        fn moderate_post(origin, post_id: T::PostId, rationale: Vec<u8>) -> DispatchResult {
 
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
@@ -772,7 +762,7 @@ decl_module! {
 }
 
 impl<T: Trait> Module<T> {
-    fn ensure_category_title_is_valid(title: &[u8]) -> dispatch::Result {
+    fn ensure_category_title_is_valid(title: &[u8]) -> DispatchResult {
         CategoryTitleConstraint::get().ensure_valid(
             title.len(),
             ERROR_CATEGORY_TITLE_TOO_SHORT,
@@ -780,7 +770,7 @@ impl<T: Trait> Module<T> {
         )
     }
 
-    fn ensure_category_description_is_valid(description: &[u8]) -> dispatch::Result {
+    fn ensure_category_description_is_valid(description: &[u8]) -> DispatchResult {
         CategoryDescriptionConstraint::get().ensure_valid(
             description.len(),
             ERROR_CATEGORY_DESCRIPTION_TOO_SHORT,
@@ -788,7 +778,7 @@ impl<T: Trait> Module<T> {
         )
     }
 
-    fn ensure_thread_moderation_rationale_is_valid(rationale: &[u8]) -> dispatch::Result {
+    fn ensure_thread_moderation_rationale_is_valid(rationale: &[u8]) -> DispatchResult {
         ThreadModerationRationaleConstraint::get().ensure_valid(
             rationale.len(),
             ERROR_THREAD_MODERATION_RATIONALE_TOO_SHORT,
@@ -796,7 +786,7 @@ impl<T: Trait> Module<T> {
         )
     }
 
-    fn ensure_thread_title_is_valid(title: &[u8]) -> dispatch::Result {
+    fn ensure_thread_title_is_valid(title: &[u8]) -> DispatchResult {
         ThreadTitleConstraint::get().ensure_valid(
             title.len(),
             ERROR_THREAD_TITLE_TOO_SHORT,
@@ -804,7 +794,7 @@ impl<T: Trait> Module<T> {
         )
     }
 
-    fn ensure_post_text_is_valid(text: &[u8]) -> dispatch::Result {
+    fn ensure_post_text_is_valid(text: &[u8]) -> DispatchResult {
         PostTextConstraint::get().ensure_valid(
             text.len(),
             ERROR_POST_TEXT_TOO_SHORT,
@@ -812,7 +802,7 @@ impl<T: Trait> Module<T> {
         )
     }
 
-    fn ensure_post_moderation_rationale_is_valid(rationale: &[u8]) -> dispatch::Result {
+    fn ensure_post_moderation_rationale_is_valid(rationale: &[u8]) -> DispatchResult {
         PostModerationRationaleConstraint::get().ensure_valid(
             rationale.len(),
             ERROR_POST_MODERATION_RATIONALE_TOO_SHORT,
@@ -840,7 +830,7 @@ impl<T: Trait> Module<T> {
         post_id: T::PostId,
     ) -> Result<Post<T::BlockNumber, T::Moment, T::AccountId, T::ThreadId, T::PostId>, &'static str>
     {
-        if <PostById<T>>::exists(post_id) {
+        if <PostById<T>>::contains_key(post_id) {
             Ok(<PostById<T>>::get(post_id))
         } else {
             Err(ERROR_POST_DOES_NOT_EXIST)
@@ -865,7 +855,7 @@ impl<T: Trait> Module<T> {
     fn ensure_thread_exists(
         thread_id: T::ThreadId,
     ) -> Result<Thread<T::BlockNumber, T::Moment, T::AccountId, T::ThreadId>, &'static str> {
-        if <ThreadById<T>>::exists(thread_id) {
+        if <ThreadById<T>>::contains_key(thread_id) {
             Ok(<ThreadById<T>>::get(thread_id))
         } else {
             Err(ERROR_THREAD_DOES_NOT_EXIST)
@@ -879,7 +869,7 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn ensure_is_forum_sudo(account_id: &T::AccountId) -> dispatch::Result {
+    fn ensure_is_forum_sudo(account_id: &T::AccountId) -> DispatchResult {
         let forum_sudo_account = Self::ensure_forum_sudo_set()?;
 
         ensure!(
@@ -901,7 +891,7 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn ensure_catgory_is_mutable(category_id: CategoryId) -> dispatch::Result {
+    fn ensure_catgory_is_mutable(category_id: CategoryId) -> DispatchResult {
         let category_tree_path = Self::build_category_tree_path(category_id);
 
         Self::ensure_can_mutate_in_path_leaf(&category_tree_path)
@@ -913,7 +903,7 @@ impl<T: Trait> Module<T> {
     #[allow(clippy::ptr_arg)]
     fn ensure_can_mutate_in_path_leaf(
         category_tree_path: &CategoryTreePath<T::BlockNumber, T::Moment, T::AccountId>,
-    ) -> dispatch::Result {
+    ) -> DispatchResult {
         // Is parent category directly or indirectly deleted or archived category
         ensure!(
             !category_tree_path.iter().any(
@@ -930,7 +920,7 @@ impl<T: Trait> Module<T> {
     #[allow(clippy::ptr_arg)] // disable it because of possible frontend API break
     fn ensure_can_add_subcategory_path_leaf(
         category_tree_path: &CategoryTreePath<T::BlockNumber, T::Moment, T::AccountId>,
-    ) -> dispatch::Result {
+    ) -> DispatchResult {
         Self::ensure_can_mutate_in_path_leaf(category_tree_path)?;
 
         // Does adding a new category exceed maximum depth
@@ -948,7 +938,7 @@ impl<T: Trait> Module<T> {
         category_id: CategoryId,
     ) -> Result<CategoryTreePath<T::BlockNumber, T::Moment, T::AccountId>, &'static str> {
         ensure!(
-            <CategoryById<T>>::exists(&category_id),
+            <CategoryById<T>>::contains_key(&category_id),
             ERROR_CATEGORY_DOES_NOT_EXIST
         );
 
@@ -990,7 +980,7 @@ impl<T: Trait> Module<T> {
 
         // Make recursive call on parent if we are not at root
         if let Some(child_position_in_parent) = position_in_parent_category_field {
-            assert!(<CategoryById<T>>::exists(
+            assert!(<CategoryById<T>>::contains_key(
                 &child_position_in_parent.parent_id
             ));
 

+ 31 - 27
runtime-modules/forum/src/mock.rs

@@ -3,22 +3,19 @@
 use crate::*;
 use common::BlockAndTime;
 
-use primitives::H256;
-
-use crate::{GenesisConfig, Module, Trait};
-use runtime_primitives::{
+use frame_support::{impl_outer_origin, parameter_types};
+use sp_core::H256;
+use sp_runtime::{
     testing::Header,
     traits::{BlakeTwo256, IdentityLookup},
     Perbill,
 };
-use srml_support::{impl_outer_origin, parameter_types};
 
 /// Module which has a full Substrate module for
 /// mocking behaviour of MembershipRegistry
 pub mod registry {
 
     use super::*;
-    // use srml_support::*;
 
     #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)]
     pub struct Member<AccountId> {
@@ -27,9 +24,8 @@ pub mod registry {
 
     decl_storage! {
         trait Store for Module<T: Trait> as MockForumUserRegistry {
-
-            pub ForumUserById get(forum_user_by_id) config(): map T::AccountId => Member<T::AccountId>;
-
+            pub ForumUserById get(fn forum_user_by_id) config(): map hasher(blake2_128_concat)
+                T::AccountId => Member<T::AccountId>;
         }
     }
 
@@ -45,7 +41,7 @@ pub mod registry {
 
     impl<T: Trait> ForumUserRegistry<T::AccountId> for Module<T> {
         fn get_forum_user(id: &T::AccountId) -> Option<ForumUser<T::AccountId>> {
-            if <ForumUserById<T>>::exists(id) {
+            if <ForumUserById<T>>::contains_key(id) {
                 let m = <ForumUserById<T>>::get(id);
 
                 Some(ForumUser { id: m.id })
@@ -74,22 +70,30 @@ parameter_types! {
 }
 
 impl system::Trait for Runtime {
+    type BaseCallFilter = ();
     type Origin = Origin;
+    type Call = ();
     type Index = u64;
     type BlockNumber = u64;
-    type Call = ();
     type Hash = H256;
     type Hashing = BlakeTwo256;
     type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
-    // type WeightMultiplierUpdate = ();
     type Event = ();
     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 = ();
+    type OnNewAccount = ();
+    type OnKilledAccount = ();
 }
 
 impl timestamp::Trait for Runtime {
@@ -168,7 +172,7 @@ pub struct CreateCategoryFixture {
     pub parent: Option<CategoryId>,
     pub title: Vec<u8>,
     pub description: Vec<u8>,
-    pub result: dispatch::Result,
+    pub result: DispatchResult,
 }
 
 impl CreateCategoryFixture {
@@ -190,7 +194,7 @@ pub struct UpdateCategoryFixture {
     pub category_id: CategoryId,
     pub new_archival_status: Option<bool>,
     pub new_deletion_status: Option<bool>,
-    pub result: dispatch::Result,
+    pub result: DispatchResult,
 }
 
 impl UpdateCategoryFixture {
@@ -212,7 +216,7 @@ pub struct CreateThreadFixture {
     pub category_id: CategoryId,
     pub title: Vec<u8>,
     pub text: Vec<u8>,
-    pub result: dispatch::Result,
+    pub result: DispatchResult,
 }
 
 impl CreateThreadFixture {
@@ -233,7 +237,7 @@ pub struct CreatePostFixture {
     pub origin: OriginType,
     pub thread_id: RuntimeThreadId,
     pub text: Vec<u8>,
-    pub result: dispatch::Result,
+    pub result: DispatchResult,
 }
 
 impl CreatePostFixture {
@@ -259,7 +263,7 @@ pub fn create_forum_member() -> OriginType {
 pub fn assert_create_category(
     forum_sudo: OriginType,
     parent_category_id: Option<CategoryId>,
-    expected_result: dispatch::Result,
+    expected_result: DispatchResult,
 ) {
     CreateCategoryFixture {
         origin: forum_sudo,
@@ -274,7 +278,7 @@ pub fn assert_create_category(
 pub fn assert_create_thread(
     forum_sudo: OriginType,
     category_id: CategoryId,
-    expected_result: dispatch::Result,
+    expected_result: DispatchResult,
 ) {
     CreateThreadFixture {
         origin: forum_sudo,
@@ -289,7 +293,7 @@ pub fn assert_create_thread(
 pub fn assert_create_post(
     forum_sudo: OriginType,
     thread_id: RuntimeThreadId,
-    expected_result: dispatch::Result,
+    expected_result: DispatchResult,
 ) {
     CreatePostFixture {
         origin: forum_sudo,
@@ -353,7 +357,7 @@ pub fn moderate_thread(
     forum_sudo: OriginType,
     thread_id: RuntimeThreadId,
     rationale: Vec<u8>,
-) -> dispatch::Result {
+) -> DispatchResult {
     TestForumModule::moderate_thread(mock_origin(forum_sudo), thread_id, rationale)
 }
 
@@ -361,28 +365,28 @@ pub fn moderate_post(
     forum_sudo: OriginType,
     post_id: RuntimePostId,
     rationale: Vec<u8>,
-) -> dispatch::Result {
+) -> DispatchResult {
     TestForumModule::moderate_post(mock_origin(forum_sudo), post_id, rationale)
 }
 
-pub fn archive_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result {
+pub fn archive_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult {
     TestForumModule::update_category(mock_origin(forum_sudo), category_id, Some(true), None)
 }
 
-pub fn unarchive_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result {
+pub fn unarchive_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult {
     TestForumModule::update_category(mock_origin(forum_sudo), category_id, Some(false), None)
 }
 
-pub fn delete_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result {
+pub fn delete_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult {
     TestForumModule::update_category(mock_origin(forum_sudo), category_id, None, Some(true))
 }
 
-pub fn undelete_category(forum_sudo: OriginType, category_id: CategoryId) -> dispatch::Result {
+pub fn undelete_category(forum_sudo: OriginType, category_id: CategoryId) -> DispatchResult {
     TestForumModule::update_category(mock_origin(forum_sudo), category_id, None, Some(false))
 }
 
 pub fn assert_not_forum_sudo_cannot_update_category(
-    update_operation: fn(OriginType, CategoryId) -> dispatch::Result,
+    update_operation: fn(OriginType, CategoryId) -> DispatchResult,
 ) {
     let config = default_genesis_config();
     let origin = OriginType::Signed(config.forum_sudo);
@@ -516,7 +520,7 @@ pub fn default_mock_forum_user_registry_genesis_config() -> registry::GenesisCon
 // NB!:
 // Wanted to have payload: a: &GenesisConfig<Test>
 // but borrow checker made my life miserabl, so giving up for now.
-pub fn build_test_externalities(config: GenesisConfig<Runtime>) -> runtime_io::TestExternalities {
+pub fn build_test_externalities(config: GenesisConfig<Runtime>) -> sp_io::TestExternalities {
     let mut t = system::GenesisConfig::default()
         .build_storage::<Runtime>()
         .unwrap();

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

@@ -3,7 +3,7 @@
 use super::*;
 use crate::mock::*;
 
-use srml_support::{assert_err, assert_ok};
+use frame_support::{assert_err, assert_ok};
 
 /*
 * NB!: No test checks for event emission!!!!