mod.rs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #![cfg(test)]
  2. use crate::{Module, Trait};
  3. use balances;
  4. use frame_support::{impl_outer_origin, parameter_types};
  5. use minting;
  6. use sp_core::H256;
  7. use sp_runtime::{
  8. testing::Header,
  9. traits::{BlakeTwo256, IdentityLookup},
  10. Perbill,
  11. };
  12. mod status_handler;
  13. pub use status_handler::MockStatusHandler;
  14. impl_outer_origin! {
  15. pub enum Origin for Test {}
  16. }
  17. // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
  18. #[derive(Clone, PartialEq, Eq, Debug)]
  19. pub struct Test;
  20. parameter_types! {
  21. pub const BlockHashCount: u64 = 250;
  22. pub const MaximumBlockWeight: u32 = 1024;
  23. pub const MaximumBlockLength: u32 = 2 * 1024;
  24. pub const AvailableBlockRatio: Perbill = Perbill::one();
  25. pub const MinimumPeriod: u64 = 5;
  26. }
  27. impl frame_system::Trait for Test {
  28. type BaseCallFilter = ();
  29. type Origin = Origin;
  30. type Call = ();
  31. type Index = u64;
  32. type BlockNumber = u64;
  33. type Hash = H256;
  34. type Hashing = BlakeTwo256;
  35. type AccountId = u64;
  36. type Lookup = IdentityLookup<Self::AccountId>;
  37. type Header = Header;
  38. type Event = ();
  39. type BlockHashCount = BlockHashCount;
  40. type MaximumBlockWeight = MaximumBlockWeight;
  41. type DbWeight = ();
  42. type BlockExecutionWeight = ();
  43. type ExtrinsicBaseWeight = ();
  44. type MaximumExtrinsicWeight = ();
  45. type MaximumBlockLength = MaximumBlockLength;
  46. type AvailableBlockRatio = AvailableBlockRatio;
  47. type Version = ();
  48. type AccountData = balances::AccountData<u64>;
  49. type OnNewAccount = ();
  50. type OnKilledAccount = ();
  51. type SystemWeightInfo = ();
  52. type PalletInfo = ();
  53. }
  54. parameter_types! {
  55. pub const ExistentialDeposit: u32 = 0;
  56. }
  57. impl balances::Trait for Test {
  58. type Balance = u64;
  59. type DustRemoval = ();
  60. type Event = ();
  61. type ExistentialDeposit = ExistentialDeposit;
  62. type AccountStore = System;
  63. type WeightInfo = ();
  64. type MaxLocks = ();
  65. }
  66. impl Trait for Test {
  67. type PayoutStatusHandler = MockStatusHandler;
  68. type RecipientId = u64;
  69. type RewardRelationshipId = u64;
  70. }
  71. impl minting::Trait for Test {
  72. type Currency = Balances;
  73. type MintId = u64;
  74. }
  75. pub fn build_test_externalities() -> sp_io::TestExternalities {
  76. MockStatusHandler::reset();
  77. let t = frame_system::GenesisConfig::default()
  78. .build_storage::<Test>()
  79. .unwrap();
  80. t.into()
  81. }
  82. pub type System = frame_system::Module<Test>;
  83. pub type Balances = balances::Module<Test>;
  84. pub type Rewards = Module<Test>;
  85. pub type Minting = minting::Module<Test>;