forked from zenlinkpro/Zenlink-DEX-Module
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmock.rs
More file actions
108 lines (97 loc) · 2.93 KB
/
Copy pathmock.rs
File metadata and controls
108 lines (97 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2021-2022 Zenlink.
// Licensed under Apache 2.0.
//! Test utilities
use frame_support::{parameter_types, PalletId};
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
};
use crate as pallet_zenlink;
pub use crate::{
AssetId, Config, MultiAssetsHandler, PairLpGenerate, Pallet, ZenlinkMultiAssets, LIQUIDITY,
LOCAL, NATIVE, RESERVED,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0,
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 8,
Zenlink: pallet_zenlink::{Pallet, Call, Storage, Event<T>} = 9,
}
);
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
pub const BlockHashCount: u64 = 250;
pub const ZenlinkPalletId: PalletId = PalletId(*b"/zenlink");
pub const NativeSwapFeesPotId: PalletId = PalletId(*b"/swpfees");
pub const MaxReserves: u32 = 50;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type RuntimeCall = RuntimeCall;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u128;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = ();
type Version = ();
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type PalletInfo = PalletInfo;
type BlockWeights = ();
type BlockLength = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
impl pallet_balances::Config for Test {
type Balance = u128;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Pallet<Test>;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
}
impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type MultiAssetsHandler = ZenlinkMultiAssets<Zenlink, Balances>;
type PalletId = ZenlinkPalletId;
type NativeSwapFeesPotId = NativeSwapFeesPotId;
type AssetId = AssetId;
type LpGenerate = PairLpGenerate<Self>;
type SelfParaId = ();
type WeightInfo = ();
}
pub type DexPallet = Pallet<Test>;
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into();
pallet_balances::GenesisConfig::<Test> {
balances: vec![
(1, 34028236692093846346337460743176821145),
(2, 10),
(3, 10),
(4, 10),
(5, 10),
],
}
.assimilate_storage(&mut t)
.unwrap();
t.into()
}