@@ -38,10 +38,11 @@ pub(crate) const ACCOUNT_00: AccountId = AccountId::new([0u8; 32]);
38
38
pub ( crate ) const ACCOUNT_01 : AccountId = AccountId :: new ( [ 1u8 ; 32 ] ) ;
39
39
const ACCOUNT_99 : AccountId = AccountId :: new ( [ 99u8 ; 32 ] ) ;
40
40
// assets
41
- pub ( crate ) const DEFAULT_BONDED_CURRENCY_ID : AssetId = 0 ;
42
- pub ( crate ) const DEFAULT_COLLATERAL_CURRENCY_ID : AssetId = AssetId :: MAX ;
41
+ pub ( crate ) const DEFAULT_BONDED_CURRENCY_ID : AssetId = 1 ;
42
+ pub ( crate ) const DEFAULT_COLLATERAL_CURRENCY_ID : AssetId = 0 ;
43
43
pub ( crate ) const DEFAULT_COLLATERAL_DENOMINATION : u8 = 10 ;
44
44
pub ( crate ) const DEFAULT_BONDED_DENOMINATION : u8 = 10 ;
45
+ pub ( crate ) const ONE_HUNDRED_KILT : u128 = 100_000_000_000_000_000 ;
45
46
46
47
// helper functions
47
48
pub fn assert_relative_eq ( target : Float , expected : Float , epsilon : Float ) {
@@ -98,7 +99,7 @@ pub mod runtime {
98
99
bonded_currencies,
99
100
state,
100
101
collateral_id,
101
- denomination : 10 ,
102
+ denomination : DEFAULT_BONDED_DENOMINATION ,
102
103
owner,
103
104
}
104
105
}
@@ -276,19 +277,24 @@ pub mod runtime {
276
277
277
278
let collateral_assets = self . collaterals . into_iter ( ) . map ( |id| ( id, ACCOUNT_99 , false , 1 ) ) ;
278
279
279
- pallet_assets:: GenesisConfig :: < Test > {
280
- assets : self
281
- . pools
282
- . iter ( )
283
- . flat_map ( |( owner, pool) | {
284
- pool. bonded_currencies
285
- . iter ( )
286
- . map ( |id| ( * id, owner. to_owned ( ) , false , 1u128 ) )
287
- . collect :: < Vec < ( AssetId , AccountId , bool , Balance ) > > ( )
288
- } )
289
- . chain ( collateral_assets)
290
- . collect ( ) ,
280
+ let all_assets: Vec < _ > = self
281
+ . pools
282
+ . iter ( )
283
+ . flat_map ( |( owner, pool) | {
284
+ pool. bonded_currencies
285
+ . iter ( )
286
+ . map ( |id| ( * id, owner. to_owned ( ) , false , 1u128 ) )
287
+ . collect :: < Vec < ( AssetId , AccountId , bool , Balance ) > > ( )
288
+ } )
289
+ . chain ( collateral_assets)
290
+ . collect ( ) ;
291
+
292
+ // NextAssetId is set to the maximum value of all collateral/bonded currency ids, plus one.
293
+ // If no currencies are created, it's set to 0.
294
+ let next_asset_id = all_assets. iter ( ) . map ( |( id, ..) | id) . max ( ) . map_or ( 0 , |id| id + 1 ) ;
291
295
296
+ pallet_assets:: GenesisConfig :: < Test > {
297
+ assets : all_assets,
292
298
accounts : self . bonded_balance ,
293
299
metadata : self
294
300
. pools
@@ -313,6 +319,8 @@ pub mod runtime {
313
319
self . pools . into_iter ( ) . for_each ( |( pool_id, pool) | {
314
320
crate :: Pools :: < Test > :: insert ( pool_id, pool) ;
315
321
} ) ;
322
+
323
+ crate :: NextAssetId :: < Test > :: set ( next_asset_id) ;
316
324
} ) ;
317
325
318
326
ext
0 commit comments