@@ -51,6 +51,8 @@ enum Panic {
5151 "Config for token '{0}' with configured balance not found in genesis"
5252 ) ]
5353 MissingTokenConfig ( String ) ,
54+ #[ error( "The MASP parameters for the native token is missing" ) ]
55+ MissingMaspParams ,
5456 #[ error( "Failed to read wasm {0} with reason: {1}" ) ]
5557 ReadingWasm ( String , String ) ,
5658}
@@ -446,13 +448,17 @@ where
446448 /// Init genesis token accounts
447449 fn init_token_accounts ( & mut self , genesis : & genesis:: chain:: Finalized ) {
448450 let mut token_map = BTreeMap :: new ( ) ;
451+ let native_alias = & genesis. parameters . parameters . native_token ;
449452 for ( alias, token) in & genesis. tokens . token {
450453 tracing:: debug!( "Initializing token {alias}" ) ;
451454
452455 let FinalizedTokenConfig {
453456 address,
454457 config : TokenConfig { denom, masp_params } ,
455458 } = token;
459+ if alias == native_alias && masp_params. is_none ( ) {
460+ self . register_err ( Panic :: MissingMaspParams ) ;
461+ }
456462 // associate a token with its denomination.
457463 write_denom ( & mut self . state , address, * denom) . unwrap ( ) ;
458464 namada_sdk:: token:: write_params (
@@ -1211,4 +1217,23 @@ mod test {
12111217 ) ] ;
12121218 assert_eq ! ( expected, initializer. warnings) ;
12131219 }
1220+
1221+ #[ test]
1222+ fn test_dry_run_native_token_masp_params ( ) {
1223+ let ( mut shell, _x, _y, _z) = TestShell :: new_at_height ( 0 ) ;
1224+ shell. wasm_dir = PathBuf :: new ( ) ;
1225+ let mut genesis = genesis:: make_dev_genesis ( 1 , & shell. base_dir ) ;
1226+ let mut initializer = InitChainValidation :: new ( & mut shell, true ) ;
1227+ genesis
1228+ . tokens
1229+ . token
1230+ . get_mut ( & genesis. parameters . parameters . native_token )
1231+ . expect ( "Test failed" )
1232+ . config
1233+ . masp_params = None ;
1234+ initializer. init_token_accounts ( & genesis) ;
1235+ let [ panic] : [ Panic ; 1 ] =
1236+ initializer. panics . clone ( ) . try_into ( ) . expect ( "Test failed" ) ;
1237+ assert_eq ! ( panic, Panic :: MissingMaspParams ) ;
1238+ }
12141239}
0 commit comments