16
16
17
17
extern crate alloc;
18
18
use polkadot_sdk:: { frame_support:: traits:: WithdrawReasons , sp_runtime:: traits:: ConvertInto , * } ;
19
- use polkadot_sdk:: sp_runtime:: traits:: AccountIdConversion ;
20
19
21
- use alloc:: collections:: BTreeMap ;
22
20
use cumulus_pallet_parachain_system:: ParachainSetCode ;
23
21
use frame_support:: {
24
- derive_impl, parameter_types,
25
- traits:: { ConstU32 , ConstU64 , Get } ,
26
- PalletId ,
22
+ derive_impl, parameter_types,
23
+ traits:: { ConstU32 , ConstU64 , Get } ,
24
+ PalletId ,
27
25
} ;
28
26
use frame_system:: { EnsureRoot , EnsureSigned , EventRecord } ;
29
- use ismp:: {
30
- consensus:: {
31
- ConsensusClient , ConsensusClientId , StateCommitment , StateMachineClient ,
32
- StateMachineHeight , StateMachineId , VerifiedCommitments ,
33
- } ,
34
- error:: Error as IsmpError ,
35
- handlers,
36
- host:: { IsmpHost , StateMachine } ,
37
- messaging:: { CreateConsensusState , Proof , StateCommitmentHeight } ,
38
- module:: IsmpModule ,
39
- router:: { IsmpRouter , PostRequest , RequestResponse , Response , Timeout } ,
40
- Error ,
41
- } ;
42
- use ismp_sync_committee:: constants:: sepolia:: Sepolia ;
43
- use pallet_ismp:: { offchain:: Leaf , ModuleId } ;
44
- use pallet_token_governor:: GatewayParams ;
45
27
use polkadot_sdk:: {
46
- pallet_session:: { disabling:: UpToLimitDisablingStrategy , SessionHandler } ,
47
- sp_runtime:: { app_crypto:: AppCrypto , traits:: OpaqueKeys } ,
48
- xcm_simulator:: { GeneralIndex , Junctions :: X3 , Location , PalletInstance , Parachain } ,
28
+ pallet_session:: { disabling:: UpToLimitDisablingStrategy , SessionHandler } ,
29
+ sp_runtime:: { app_crypto:: AppCrypto , traits:: OpaqueKeys } ,
30
+ xcm_simulator:: { GeneralIndex , Junctions :: X3 , Location , PalletInstance , Parachain } ,
49
31
} ;
50
32
use sp_consensus_aura:: sr25519:: AuthorityId as AuraId ;
51
33
use sp_core:: {
52
- offchain:: { testing:: TestOffchainExt , OffchainDbExt , OffchainWorkerExt } ,
53
- H160 , H256 , U256 ,
34
+ offchain:: { testing:: TestOffchainExt , OffchainDbExt , OffchainWorkerExt } ,
35
+ H160 , H256 , U256 ,
54
36
} ;
55
37
use sp_runtime:: {
56
- traits:: { IdentityLookup , Keccak256 } ,
57
- AccountId32 , BuildStorage ,
38
+ traits:: { IdentityLookup , Keccak256 } ,
39
+ AccountId32 , BuildStorage ,
58
40
} ;
59
41
60
42
use crate :: asset_hub_runtime:: sp_runtime:: DispatchError ;
61
- use hyperbridge_client_machine:: HyperbridgeClientMachine ;
62
- use pallet_messaging_fees:: types:: PriceOracle ;
63
43
use pallet_xcm_gateway:: xcm_utilities:: ASSET_HUB_PARA_ID ;
64
- use substrate_state_machine:: SubstrateStateMachine ;
65
44
use xcm_simulator:: mock_message_queue;
66
45
pub const ALICE : AccountId32 = AccountId32 :: new ( [ 1 ; 32 ] ) ;
67
46
pub const BOB : AccountId32 = AccountId32 :: new ( [ 2 ; 32 ] ) ;
@@ -78,36 +57,25 @@ frame_support::construct_runtime!(
78
57
System : frame_system,
79
58
ParachainSystem : cumulus_pallet_parachain_system,
80
59
ParachainInfo : staging_parachain_info,
81
- Timestamp : pallet_timestamp,
82
60
Balances : pallet_balances,
83
61
XcmpQueue : cumulus_pallet_xcmp_queue,
84
62
MessageQueue : pallet_message_queue,
85
63
PalletXcm : pallet_xcm,
86
64
Assets : pallet_assets,
87
- Sudo : pallet_sudo,
88
- Vesting : pallet_vesting,
89
65
MsgQueue : mock_message_queue
90
66
}
91
67
) ;
92
68
93
69
/// Verify the the last event emitted
94
70
pub fn assert_last_event < T : frame_system:: Config > ( generic_event : T :: RuntimeEvent ) {
95
- assert_eq ! ( last_event:: <T >( ) , generic_event) ;
71
+ assert_eq ! ( last_event:: <T >( ) , generic_event) ;
96
72
}
97
73
98
74
/// Verify the the last event emitted
99
75
pub fn last_event < T : frame_system:: Config > ( ) -> T :: RuntimeEvent {
100
- let events = frame_system:: Pallet :: < T > :: events ( ) ;
101
- let EventRecord { event, .. } = & events[ events. len ( ) - 1 ] ;
102
- event. clone ( )
103
- }
104
-
105
- pub struct StateMachineProvider ;
106
-
107
- impl Get < StateMachine > for StateMachineProvider {
108
- fn get ( ) -> StateMachine {
109
- StateMachine :: Kusama ( 100 )
110
- }
76
+ let events = frame_system:: Pallet :: < T > :: events ( ) ;
77
+ let EventRecord { event, .. } = & events[ events. len ( ) - 1 ] ;
78
+ event. clone ( )
111
79
}
112
80
113
81
/// Balance of an account.
@@ -125,166 +93,72 @@ parameter_types! {
125
93
}
126
94
127
95
impl pallet_balances:: Config for AssetHubTest {
128
- /// The ubiquitous event type.
129
- type RuntimeEvent = RuntimeEvent ;
130
- type RuntimeHoldReason = RuntimeHoldReason ;
131
- type RuntimeFreezeReason = RuntimeFreezeReason ;
132
- type WeightInfo = pallet_balances:: weights:: SubstrateWeight < AssetHubTest > ;
133
- /// The type for recording an account's balance.
134
- type Balance = Balance ;
135
- type DustRemoval = ( ) ;
136
- type ExistentialDeposit = ExistentialDeposit ;
137
- type AccountStore = System ;
138
- type ReserveIdentifier = [ u8 ; 8 ] ;
139
- type FreezeIdentifier = ( ) ;
140
- type MaxLocks = ConstU32 < 50 > ;
141
- type MaxReserves = ConstU32 < 50 > ;
142
- type MaxFreezes = ( ) ;
143
- type DoneSlashHandler = ( ) ;
144
- }
145
-
146
-
147
-
148
- impl pallet_sudo:: Config for AssetHubTest {
149
- type RuntimeEvent = RuntimeEvent ;
150
- type RuntimeCall = RuntimeCall ;
151
- type WeightInfo = ( ) ;
96
+ /// The ubiquitous event type.
97
+ type RuntimeEvent = RuntimeEvent ;
98
+ type RuntimeHoldReason = RuntimeHoldReason ;
99
+ type RuntimeFreezeReason = RuntimeFreezeReason ;
100
+ type WeightInfo = pallet_balances:: weights:: SubstrateWeight < AssetHubTest > ;
101
+ /// The type for recording an account's balance.
102
+ type Balance = Balance ;
103
+ type DustRemoval = ( ) ;
104
+ type ExistentialDeposit = ExistentialDeposit ;
105
+ type AccountStore = System ;
106
+ type ReserveIdentifier = [ u8 ; 8 ] ;
107
+ type FreezeIdentifier = ( ) ;
108
+ type MaxLocks = ConstU32 < 50 > ;
109
+ type MaxReserves = ConstU32 < 50 > ;
110
+ type MaxFreezes = ( ) ;
111
+ type DoneSlashHandler = ( ) ;
152
112
}
153
113
154
114
#[ derive_impl( frame_system:: config_preludes:: ParaChainDefaultConfig as frame_system:: DefaultConfig ) ]
155
115
impl frame_system:: Config for AssetHubTest {
156
- type BaseCallFilter = frame_support:: traits:: Everything ;
157
- type RuntimeOrigin = RuntimeOrigin ;
158
- type RuntimeCall = RuntimeCall ;
159
- type Hash = H256 ;
160
- type Hashing = Keccak256 ;
161
- type AccountId = AccountId32 ;
162
- type Lookup = IdentityLookup < Self :: AccountId > ;
163
- type RuntimeEvent = RuntimeEvent ;
164
- type BlockHashCount = ConstU64 < 250 > ;
165
- type DbWeight = ( ) ;
166
- type BlockWeights = ( ) ;
167
- type RuntimeTask = ( ) ;
168
- type BlockLength = ( ) ;
169
- type Version = ( ) ;
170
- type Nonce = u64 ;
171
- type Block = Block ;
172
- type PalletInfo = PalletInfo ;
173
- type AccountData = pallet_balances:: AccountData < Balance > ;
174
- type OnNewAccount = ( ) ;
175
- type OnKilledAccount = ( ) ;
176
- type SystemWeightInfo = ( ) ;
177
- type SS58Prefix = ( ) ;
178
- type OnSetCode = ParachainSetCode < AssetHubTest > ;
179
- type MaxConsumers = ConstU32 < 16 > ;
180
- }
181
-
182
- impl pallet_timestamp:: Config for AssetHubTest {
183
- type Moment = u64 ;
184
- type OnTimestampSet = ( ) ;
185
- type MinimumPeriod = ConstU64 < 1 > ;
186
- type WeightInfo = ( ) ;
116
+ type BaseCallFilter = frame_support:: traits:: Everything ;
117
+ type RuntimeOrigin = RuntimeOrigin ;
118
+ type RuntimeCall = RuntimeCall ;
119
+ type Hash = H256 ;
120
+ type Hashing = Keccak256 ;
121
+ type AccountId = AccountId32 ;
122
+ type Lookup = IdentityLookup < Self :: AccountId > ;
123
+ type RuntimeEvent = RuntimeEvent ;
124
+ type BlockHashCount = ConstU64 < 250 > ;
125
+ type DbWeight = ( ) ;
126
+ type BlockWeights = ( ) ;
127
+ type RuntimeTask = ( ) ;
128
+ type BlockLength = ( ) ;
129
+ type Version = ( ) ;
130
+ type Nonce = u64 ;
131
+ type Block = Block ;
132
+ type PalletInfo = PalletInfo ;
133
+ type AccountData = pallet_balances:: AccountData < Balance > ;
134
+ type OnNewAccount = ( ) ;
135
+ type OnKilledAccount = ( ) ;
136
+ type SystemWeightInfo = ( ) ;
137
+ type SS58Prefix = ( ) ;
138
+ type OnSetCode = ParachainSetCode < AssetHubTest > ;
139
+ type MaxConsumers = ConstU32 < 16 > ;
187
140
}
188
141
189
- parameter_types ! {
190
- pub const Coprocessor : Option <StateMachine > = Some ( StateMachine :: Polkadot ( 3367 ) ) ;
191
- }
192
-
193
-
194
-
195
142
parameter_types ! {
196
143
pub const Decimals : u8 = 10 ;
197
144
}
198
145
199
146
pub struct NativeAssetId ;
200
147
201
148
impl Get < H256 > for NativeAssetId {
202
- fn get ( ) -> H256 {
203
- sp_io:: hashing:: keccak_256 ( b"BRIDGE" ) . into ( )
204
- }
149
+ fn get ( ) -> H256 {
150
+ sp_io:: hashing:: keccak_256 ( b"BRIDGE" ) . into ( )
151
+ }
205
152
}
206
153
207
-
208
-
209
154
sp_runtime:: impl_opaque_keys! {
210
155
pub struct SessionKeys {
211
156
pub aura: AuraId ,
212
157
}
213
158
}
214
159
215
- pub struct TestSessionHandler ;
216
- impl SessionHandler < AccountId32 > for TestSessionHandler {
217
- const KEY_TYPE_IDS : & ' static [ sp_runtime:: KeyTypeId ] = & [ AuraId :: ID ] ;
218
-
219
- fn on_genesis_session < T : OpaqueKeys > ( _validators : & [ ( AccountId32 , T ) ] ) { }
220
-
221
- fn on_new_session < T : OpaqueKeys > (
222
- _changed : bool ,
223
- _validators : & [ ( AccountId32 , T ) ] ,
224
- _queued_validators : & [ ( AccountId32 , T ) ] ,
225
- ) {
226
- }
227
-
228
- fn on_disabled ( _validator_index : u32 ) { }
229
-
230
- fn on_before_session_ending ( ) { }
231
- }
232
-
233
-
234
- parameter_types ! {
235
- pub const PotId : PalletId = PalletId ( * b"PotStake" ) ;
236
- pub const MaxCandidates : u32 = 100 ;
237
- pub const MaxInvulnerables : u32 = 20 ;
238
- pub const DesiredCollators : u32 = 2 ;
239
- }
240
-
241
-
242
-
243
-
244
-
245
-
246
- parameter_types ! {
247
- pub const TreasuryAccount : PalletId = PalletId ( * b"treasury" ) ;
248
- }
249
-
250
- pub struct MockPriceOracle ;
251
-
252
- impl PriceOracle for MockPriceOracle {
253
- fn get_bridge_price ( ) -> Result < U256 , DispatchError > {
254
- // return 0.05 with 18 decimals: 0.05 * 10^18
255
- Ok ( U256 :: from ( 50_000_000_000_000_000u128 ) )
256
- }
257
- }
258
-
259
- parameter_types ! {
260
- pub const MinVestedTransfer : u64 = 256 * 2 ;
261
- pub UnvestedFundsAllowedWithdrawReasons : WithdrawReasons =
262
- WithdrawReasons :: except( WithdrawReasons :: TRANSFER | WithdrawReasons :: RESERVE ) ;
263
- }
264
-
265
- impl pallet_vesting:: Config for AssetHubTest {
266
- type BlockNumberToBalance = ConvertInto ;
267
- type Currency = Balances ;
268
- type RuntimeEvent = RuntimeEvent ;
269
- const MAX_VESTING_SCHEDULES : u32 = 3 ;
270
- type MinVestedTransfer = MinVestedTransfer ;
271
- type WeightInfo = ( ) ;
272
- type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons ;
273
- type BlockNumberProvider = System ;
274
- }
275
-
276
-
277
- pub fn set_timestamp < T : pallet_timestamp:: Config > ( value : u64 )
278
- where
279
- <T as pallet_timestamp:: Config >:: Moment : From < u64 > ,
280
- {
281
- pallet_timestamp:: Pallet :: < T > :: set_timestamp ( value. into ( ) ) ;
282
- }
283
-
284
-
285
160
pub fn register_offchain_ext ( ext : & mut sp_io:: TestExternalities ) {
286
- let ( offchain, _offchain_state) = TestOffchainExt :: with_offchain_db ( ext. offchain_db ( ) ) ;
287
- ext. register_extension ( OffchainDbExt :: new ( offchain. clone ( ) ) ) ;
288
- ext. register_extension ( OffchainWorkerExt :: new ( offchain) ) ;
161
+ let ( offchain, _offchain_state) = TestOffchainExt :: with_offchain_db ( ext. offchain_db ( ) ) ;
162
+ ext. register_extension ( OffchainDbExt :: new ( offchain. clone ( ) ) ) ;
163
+ ext. register_extension ( OffchainWorkerExt :: new ( offchain) ) ;
289
164
}
290
-
0 commit comments