@@ -38,10 +38,11 @@ pub(crate) const ACCOUNT_00: AccountId = AccountId::new([0u8; 32]);
3838pub ( crate ) const ACCOUNT_01 : AccountId = AccountId :: new ( [ 1u8 ; 32 ] ) ;
3939const ACCOUNT_99 : AccountId = AccountId :: new ( [ 99u8 ; 32 ] ) ;
4040// 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 ;
4343pub ( crate ) const DEFAULT_COLLATERAL_DENOMINATION : u8 = 10 ;
4444pub ( crate ) const DEFAULT_BONDED_DENOMINATION : u8 = 10 ;
45+ pub ( crate ) const ONE_HUNDRED_KILT : u128 = 100_000_000_000_000_000 ;
4546
4647// helper functions
4748pub fn assert_relative_eq ( target : Float , expected : Float , epsilon : Float ) {
@@ -98,7 +99,7 @@ pub mod runtime {
9899 bonded_currencies,
99100 state,
100101 collateral_id,
101- denomination : 10 ,
102+ denomination : DEFAULT_BONDED_DENOMINATION ,
102103 owner,
103104 }
104105 }
@@ -276,19 +277,24 @@ pub mod runtime {
276277
277278 let collateral_assets = self . collaterals . into_iter ( ) . map ( |id| ( id, ACCOUNT_99 , false , 1 ) ) ;
278279
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 ) ;
291295
296+ pallet_assets:: GenesisConfig :: < Test > {
297+ assets : all_assets,
292298 accounts : self . bonded_balance ,
293299 metadata : self
294300 . pools
@@ -313,6 +319,8 @@ pub mod runtime {
313319 self . pools . into_iter ( ) . for_each ( |( pool_id, pool) | {
314320 crate :: Pools :: < Test > :: insert ( pool_id, pool) ;
315321 } ) ;
322+
323+ crate :: NextAssetId :: < Test > :: set ( next_asset_id) ;
316324 } ) ;
317325
318326 ext
0 commit comments