123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #![cfg(test)]
- use frame_support::dispatch::DispatchError;
- use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
- use sp_core::H256;
- use sp_runtime::{
- testing::Header,
- traits::{BlakeTwo256, IdentityLookup},
- Perbill,
- };
- use crate::{Module, Trait};
- impl_outer_origin! {
- pub enum Origin for Test {}
- }
- mod bounty {
- pub use crate::Event;
- }
- impl_outer_event! {
- pub enum TestEvent for Test {
- bounty<T>,
- frame_system<T>,
- balances<T>,
- }
- }
- // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
- #[derive(Clone, PartialEq, Eq, Debug)]
- pub struct Test;
- parameter_types! {
- pub const BlockHashCount: u64 = 250;
- pub const MaximumBlockWeight: u32 = 1024;
- pub const MaximumBlockLength: u32 = 2 * 1024;
- pub const AvailableBlockRatio: Perbill = Perbill::one();
- }
- impl frame_system::Trait for Test {
- type BaseCallFilter = ();
- type Origin = Origin;
- type Call = ();
- type Index = u64;
- type BlockNumber = u64;
- type Hash = H256;
- type Hashing = BlakeTwo256;
- type AccountId = u64;
- type Lookup = IdentityLookup<Self::AccountId>;
- type Header = Header;
- type Event = TestEvent;
- type BlockHashCount = BlockHashCount;
- type MaximumBlockWeight = MaximumBlockWeight;
- type DbWeight = ();
- type BlockExecutionWeight = ();
- type ExtrinsicBaseWeight = ();
- type MaximumExtrinsicWeight = ();
- type MaximumBlockLength = MaximumBlockLength;
- type AvailableBlockRatio = AvailableBlockRatio;
- type Version = ();
- type AccountData = balances::AccountData<u64>;
- type OnNewAccount = ();
- type OnKilledAccount = ();
- type PalletInfo = ();
- type SystemWeightInfo = ();
- }
- impl Trait for Test {
- type Event = TestEvent;
- type BountyId = u64;
- type MemberOriginValidator = ();
- type WeightInfo = ();
- }
- impl crate::WeightInfo for () {
- fn create_bounty(_: u32) -> u64 {
- 0
- }
- }
- impl common::Trait for Test {
- type MemberId = u64;
- type ActorId = u64;
- }
- impl common::origin::MemberOriginValidator<Origin, u64, u64> for () {
- fn ensure_member_controller_account_origin(
- origin: Origin,
- _account_id: u64,
- ) -> Result<u64, DispatchError> {
- let signed_account_id = frame_system::ensure_signed(origin)?;
- Ok(signed_account_id)
- }
- fn is_member_controller_account(_member_id: &u64, _account_id: &u64) -> bool {
- true
- }
- }
- parameter_types! {
- pub const ExistentialDeposit: u32 = 0;
- }
- impl balances::Trait for Test {
- type Balance = u64;
- type DustRemoval = ();
- type Event = TestEvent;
- type ExistentialDeposit = ExistentialDeposit;
- type AccountStore = System;
- type WeightInfo = ();
- type MaxLocks = ();
- }
- pub fn build_test_externalities() -> sp_io::TestExternalities {
- let t = frame_system::GenesisConfig::default()
- .build_storage::<Test>()
- .unwrap();
- t.into()
- }
- pub type System = frame_system::Module<Test>;
- pub type Bounty = Module<Test>;
|