Переглянути джерело

runtime: Migrate runtime tests.

Shamil Gadelshin 4 роки тому
батько
коміт
a6ce0324ef
32 змінених файлів з 63 додано та 17 видалено
  1. 4 0
      Cargo.lock
  2. 3 0
      runtime-modules/content-working-group/src/lib.rs
  3. 2 0
      runtime-modules/forum/Cargo.toml
  4. 3 0
      runtime-modules/forum/src/lib.rs
  5. 2 0
      runtime-modules/governance/src/council.rs
  6. 2 0
      runtime-modules/governance/src/election.rs
  7. 1 0
      runtime-modules/hiring/src/lib.rs
  8. 2 0
      runtime-modules/membership/Cargo.toml
  9. 3 0
      runtime-modules/membership/src/lib.rs
  10. 2 0
      runtime-modules/memo/Cargo.toml
  11. 1 0
      runtime-modules/memo/src/lib.rs
  12. 1 0
      runtime-modules/proposals/discussion/src/types.rs
  13. 1 0
      runtime-modules/proposals/engine/src/lib.rs
  14. 2 1
      runtime-modules/proposals/engine/src/types/mod.rs
  15. 3 2
      runtime-modules/proposals/engine/src/types/proposal_statuses.rs
  16. 2 0
      runtime-modules/service-discovery/Cargo.toml
  17. 1 0
      runtime-modules/service-discovery/src/lib.rs
  18. 1 0
      runtime-modules/storage/src/data_directory.rs
  19. 1 0
      runtime-modules/storage/src/data_object_storage_registry.rs
  20. 1 0
      runtime-modules/storage/src/data_object_type_registry.rs
  21. 1 0
      runtime-modules/versioned-store-permissions/src/credentials.rs
  22. 1 0
      runtime-modules/versioned-store-permissions/src/lib.rs
  23. 2 0
      runtime-modules/versioned-store-permissions/src/operations.rs
  24. 2 0
      runtime-modules/versioned-store/src/lib.rs
  25. 1 0
      runtime-modules/working-group/src/lib.rs
  26. 3 2
      runtime/Cargo.toml
  27. 1 1
      runtime/src/integration/proposals/council_origin_validator.rs
  28. 2 2
      runtime/src/integration/proposals/membership_origin_validator.rs
  29. 4 2
      runtime/src/lib.rs
  30. 1 1
      runtime/src/tests/mod.rs
  31. 7 5
      runtime/src/tests/proposals_integration/mod.rs
  32. 0 1
      runtime/src/tests/proposals_integration/working_group_proposals.rs

+ 4 - 0
Cargo.lock

@@ -1773,6 +1773,7 @@ dependencies = [
  "sp-core",
  "sp-io",
  "sp-runtime",
+ "sp-std",
 ]
 
 [[package]]
@@ -1884,6 +1885,7 @@ dependencies = [
  "sp-core",
  "sp-io",
  "sp-runtime",
+ "sp-std",
 ]
 
 [[package]]
@@ -1895,6 +1897,7 @@ dependencies = [
  "pallet-common",
  "parity-scale-codec",
  "sp-arithmetic",
+ "sp-std",
 ]
 
 [[package]]
@@ -2032,6 +2035,7 @@ dependencies = [
  "sp-core",
  "sp-io",
  "sp-runtime",
+ "sp-std",
 ]
 
 [[package]]

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

@@ -23,6 +23,9 @@ use codec::{Decode, Encode};
 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 rstd::vec;
+use rstd::vec::Vec;
+use rstd::borrow::ToOwned;
 use sp_arithmetic::traits::{One, Zero};
 use system::{ensure_root, ensure_signed};
 

+ 2 - 0
runtime-modules/forum/Cargo.toml

@@ -11,6 +11,7 @@ frame-support = { package = 'frame-support', default-features = false, git = 'ht
 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'}
+rstd = { package = 'sp-std', 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'}
 
@@ -25,6 +26,7 @@ std = [
 	'codec/std',
 	'frame-support/std',
 	'system/std',
+	'rstd/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'timestamp/std',

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

@@ -17,6 +17,9 @@ use codec::{Codec, Decode, Encode};
 use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter};
 use sp_arithmetic::traits::{BaseArithmetic, One};
 use sp_runtime::traits::{MaybeSerialize, Member};
+use rstd::vec;
+use rstd::vec::Vec;
+use rstd::borrow::ToOwned;
 
 mod mock;
 mod tests;

+ 2 - 0
runtime-modules/governance/src/council.rs

@@ -1,6 +1,8 @@
 use frame_support::{debug, decl_event, decl_module, decl_storage, ensure};
 use sp_arithmetic::traits::{One, Zero};
 use system::ensure_root;
+use rstd::vec;
+use rstd::vec::Vec;
 
 pub use super::election::{self, CouncilElected, Seat, Seats};
 pub use common::currency::{BalanceOf, GovernanceCurrency};

+ 2 - 0
runtime-modules/governance/src/election.rs

@@ -37,6 +37,8 @@ use frame_support::traits::{Currency, ReservableCurrency};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
 use rstd::collections::btree_map::BTreeMap;
 use rstd::ops::Add;
+use rstd::vec;
+use rstd::vec::Vec;
 use sp_arithmetic::traits::Zero;
 use sp_runtime::traits::Hash;
 use system::{ensure_root, ensure_signed};

+ 1 - 0
runtime-modules/hiring/src/lib.rs

@@ -33,6 +33,7 @@ use rstd::collections::btree_map::BTreeMap;
 use rstd::collections::btree_set::BTreeSet;
 use rstd::iter::Iterator;
 use rstd::rc::Rc;
+use rstd::vec::Vec;
 use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
 use sp_runtime::traits::{MaybeSerialize, Member};
 

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

@@ -7,6 +7,7 @@ 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'}
@@ -26,6 +27,7 @@ std = [
 	'codec/std',
 	'frame-support/std',
 	'system/std',
+	'rstd/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'timestamp/std',

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

@@ -15,6 +15,9 @@ use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter};
 use sp_arithmetic::traits::{BaseArithmetic, One};
 use sp_runtime::traits::{MaybeSerialize, Member};
 use system::{ensure_root, ensure_signed};
+use rstd::vec;
+use rstd::vec::Vec;
+use rstd::borrow::ToOwned;
 
 use common::currency::{BalanceOf, GovernanceCurrency};
 

+ 2 - 0
runtime-modules/memo/Cargo.toml

@@ -7,6 +7,7 @@ edition = '2018'
 [dependencies]
 codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
 sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+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'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
@@ -16,6 +17,7 @@ default = ['std']
 std = [
 	'codec/std',
 	'sp-arithmetic/std',
+	'rstd/std',
 	'frame-support/std',
 	'system/std',
 	'common/std',

+ 1 - 0
runtime-modules/memo/src/lib.rs

@@ -4,6 +4,7 @@
 use frame_support::traits::Currency;
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
 use sp_arithmetic::traits::Zero;
+use rstd::vec::Vec;
 use system::ensure_signed;
 
 use common::currency::GovernanceCurrency;

+ 1 - 0
runtime-modules/proposals/discussion/src/types.rs

@@ -3,6 +3,7 @@
 use codec::{Decode, Encode};
 #[cfg(feature = "std")]
 use serde::{Deserialize, Serialize};
+use rstd::vec::Vec;
 
 /// Represents a discussion thread
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]

+ 1 - 0
runtime-modules/proposals/engine/src/lib.rs

@@ -136,6 +136,7 @@ use frame_support::{
 };
 use sp_arithmetic::traits::Zero;
 use system::{ensure_root, RawOrigin};
+use rstd::vec::Vec;
 
 use common::origin::ActorOriginValidator;
 

+ 2 - 1
runtime-modules/proposals/engine/src/types/mod.rs

@@ -6,7 +6,8 @@
 use codec::{Decode, Encode};
 use rstd::cmp::PartialOrd;
 use rstd::ops::Add;
-
+use rstd::vec::Vec;
+use rstd::boxed::Box;
 use frame_support::dispatch::DispatchResult;
 use frame_support::traits::Currency;
 #[cfg(feature = "std")]

+ 3 - 2
runtime-modules/proposals/engine/src/types/proposal_statuses.rs

@@ -1,10 +1,11 @@
 #![warn(missing_docs)]
 
 use codec::{Decode, Encode};
-
-use crate::ActiveStake;
 #[cfg(feature = "std")]
 use serde::{Deserialize, Serialize};
+use rstd::vec::Vec;
+
+use crate::ActiveStake;
 
 /// Current status of the proposal
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]

+ 2 - 0
runtime-modules/service-discovery/Cargo.toml

@@ -7,6 +7,7 @@ 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-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
@@ -29,6 +30,7 @@ default = ['std']
 std = [
 	'serde',
 	'codec/std',
+	'rstd/std',
 	'frame-support/std',
 	'system/std',
 	'sp-runtime/std',

+ 1 - 0
runtime-modules/service-discovery/src/lib.rs

@@ -27,6 +27,7 @@ use codec::{Decode, Encode};
 use serde::{Deserialize, Serialize};
 
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
+use rstd::vec::Vec;
 use system::ensure_root;
 /*
   Although there is support for ed25519 keys as the IPNS identity key and we could potentially

+ 1 - 0
runtime-modules/storage/src/data_directory.rs

@@ -26,6 +26,7 @@ use frame_support::dispatch::DispatchResult;
 use frame_support::traits::Get;
 use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter};
 use rstd::collections::btree_map::BTreeMap;
+use rstd::vec::Vec;
 use sp_runtime::traits::{MaybeSerialize, Member};
 use system::ensure_root;
 

+ 1 - 0
runtime-modules/storage/src/data_object_storage_registry.rs

@@ -27,6 +27,7 @@ use frame_support::dispatch::DispatchResult;
 use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter};
 use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerialize, Member};
+use rstd::vec::Vec;
 
 use crate::data_directory::{self, ContentIdExists};
 use crate::{StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance};

+ 1 - 0
runtime-modules/storage/src/data_object_type_registry.rs

@@ -28,6 +28,7 @@ use frame_support::weights::Weight;
 use frame_support::{decl_error, decl_event, decl_module, decl_storage, Parameter};
 use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerialize, Member};
+use rstd::vec::Vec;
 
 use crate::{StorageWorkingGroup, StorageWorkingGroupInstance};
 

+ 1 - 0
runtime-modules/versioned-store-permissions/src/credentials.rs

@@ -1,5 +1,6 @@
 use codec::{Decode, Encode};
 use rstd::collections::btree_set::BTreeSet;
+use rstd::vec::Vec;
 
 #[derive(Encode, Decode, Eq, PartialEq, Clone, Debug)]
 pub struct CredentialSet<Credential>(BTreeSet<Credential>);

+ 1 - 0
runtime-modules/versioned-store-permissions/src/lib.rs

@@ -4,6 +4,7 @@
 use codec::Codec;
 use frame_support::{decl_module, decl_storage, ensure, Parameter};
 use rstd::collections::btree_map::BTreeMap;
+use rstd::vec::Vec;
 use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerialize, Member};
 

+ 2 - 0
runtime-modules/versioned-store-permissions/src/operations.rs

@@ -1,5 +1,7 @@
 use codec::{Decode, Encode};
 use rstd::collections::btree_map::BTreeMap;
+use rstd::vec;
+use rstd::vec::Vec;
 use versioned_store::{ClassId, ClassPropertyValue, EntityId, PropertyValue};
 
 #[derive(Encode, Decode, Eq, PartialEq, Clone, Debug)]

+ 2 - 0
runtime-modules/versioned-store/src/lib.rs

@@ -17,6 +17,8 @@ use serde::{Deserialize, Serialize};
 use codec::{Decode, Encode};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
 use rstd::collections::btree_set::BTreeSet;
+use rstd::vec;
+use rstd::vec::Vec;
 
 mod example;
 mod mock;

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

@@ -58,6 +58,7 @@ use frame_support::traits::{Currency, ExistenceRequirement, Get, Imbalance, With
 use frame_support::{decl_event, decl_module, decl_storage, ensure, print, StorageValue};
 use rstd::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
 use rstd::vec::Vec;
+use rstd::vec;
 use sp_arithmetic::traits::{Bounded, One, Zero};
 use system::{ensure_root, ensure_signed};
 

+ 3 - 2
runtime/Cargo.toml

@@ -16,7 +16,6 @@ rstd = { package = 'sp-std', default-features = false, git = 'https://github.com
 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'}
 sp-offchain = { package = 'sp-offchain', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-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'}
 sp-authority-discovery = { package = 'sp-authority-discovery', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 sp-consensus-babe = { package = 'sp-consensus-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
@@ -72,6 +71,9 @@ proposals-engine = { package = 'pallet-proposals-engine', default-features = fal
 proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../runtime-modules/proposals/discussion'}
 proposals-codex = { package = 'pallet-proposals-codex', default-features = false, path = '../runtime-modules/proposals/codex'}
 
+[dev-dependencies]
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+
 [build-dependencies]
 wasm-builder-runner = { package = "substrate-wasm-builder-runner", git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
 
@@ -85,7 +87,6 @@ std = [
 
     # Substrate primitives
     'rstd/std',
-    'sp-io/std',
     'sp-core/std',
     'sp-api/std',
     'sp-version/std',

+ 1 - 1
runtime/src/integration/proposals/council_origin_validator.rs

@@ -46,7 +46,7 @@ mod tests {
     use crate::Runtime;
     use common::origin::ActorOriginValidator;
     use proposals_engine::VotersParameters;
-    use sr_primitives::AccountId32;
+    use sp_runtime::AccountId32;
     use system::RawOrigin;
 
     type Council = governance::council::Module<Runtime>;

+ 2 - 2
runtime/src/integration/proposals/membership_origin_validator.rs

@@ -47,12 +47,12 @@ mod tests {
     use super::MembershipOriginValidator;
     use crate::Runtime;
     use common::origin::ActorOriginValidator;
-    use sr_primitives::AccountId32;
+    use sp_runtime::AccountId32;
     use system::RawOrigin;
 
     type Membership = membership::Module<Runtime>;
 
-    fn initial_test_ext() -> runtime_io::TestExternalities {
+    fn initial_test_ext() -> sp_io::TestExternalities {
         let t = system::GenesisConfig::default()
             .build_storage::<Runtime>()
             .unwrap();

+ 4 - 2
runtime/src/lib.rs

@@ -30,20 +30,22 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
 use sp_api::impl_runtime_apis;
 use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
 use sp_core::crypto::KeyTypeId;
+use rstd::vec::Vec;
+use rstd::boxed::Box;
 use sp_core::OpaqueMetadata;
 use sp_runtime::curve::PiecewiseLinear;
 use sp_runtime::traits::{
     BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, StaticLookup, Verify,
 };
 use sp_runtime::transaction_validity::TransactionSource;
-#[cfg(any(feature = "std", test))]
 use sp_runtime::Perbill;
 use sp_runtime::{
     create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity,
     ApplyExtrinsicResult, MultiSignature,
 };
 #[cfg(feature = "std")]
-use sp_version::{NativeVersion, RuntimeVersion};
+use sp_version::{NativeVersion};
+use sp_version::{RuntimeVersion};
 use system::EnsureRoot;
 
 use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator};

+ 1 - 1
runtime/src/tests/mod.rs

@@ -5,7 +5,7 @@
 mod proposals_integration;
 mod storage_integration;
 
-pub(crate) fn initial_test_ext() -> runtime_io::TestExternalities {
+pub(crate) fn initial_test_ext() -> sp_io::TestExternalities {
     let t = system::GenesisConfig::default()
         .build_storage::<crate::Runtime>()
         .unwrap();

+ 7 - 5
runtime/src/tests/proposals_integration/mod.rs

@@ -4,7 +4,8 @@
 
 mod working_group_proposals;
 
-use crate::{BlockNumber, ElectionParameters, ProposalCancellationFee, Runtime};
+use crate::{BlockNumber, ProposalCancellationFee, Runtime};
+use governance::election_params::ElectionParameters;
 use codec::Encode;
 use membership;
 use proposals_engine::{
@@ -13,10 +14,11 @@ use proposals_engine::{
     VotingResults,
 };
 
-use sr_primitives::traits::{DispatchResult, OnFinalize, OnInitialize};
-use sr_primitives::AccountId32;
-use srml_support::traits::Currency;
-use srml_support::{StorageLinkedMap, StorageValue};
+use frame_support::dispatch::{DispatchResult};
+use sp_runtime::traits::{OnFinalize, OnInitialize};
+use sp_runtime::AccountId32;
+use frame_support::traits::Currency;
+use frame_support::{IterableStorageMap, StorageValue};
 use system::RawOrigin;
 
 use super::initial_test_ext;

+ 0 - 1
runtime/src/tests/proposals_integration/working_group_proposals.rs

@@ -1,6 +1,5 @@
 use super::*;
 
-use srml_support::StorageLinkedMap;
 use system::RawOrigin;
 
 use common::working_group::WorkingGroup;