@@ -850,14 +850,15 @@ mod tests {
850850 for ( build_spec_cmd, chain) in [
851851 // No flags used.
852852 ( BuildSpecCommand :: default ( ) , None ) ,
853- // All flags used.
853+ // All flags used. Parachain
854854 (
855855 BuildSpecCommand {
856856 path,
857857 output_file : Some ( PathBuf :: from ( output_file) ) ,
858858 profile : Some ( profile. clone ( ) ) ,
859859 name : Some ( name. to_string ( ) ) ,
860860 id : Some ( id. to_string ( ) ) ,
861+ is_relay : false ,
861862 para_id : Some ( para_id) ,
862863 default_bootnode : Some ( default_bootnode) ,
863864 chain_type : Some ( chain_type. clone ( ) ) ,
@@ -875,6 +876,32 @@ mod tests {
875876 } ,
876877 Some ( "local" . to_string ( ) ) ,
877878 ) ,
879+ // All flags used. Relay
880+ (
881+ BuildSpecCommand {
882+ path,
883+ output_file : Some ( PathBuf :: from ( output_file) ) ,
884+ profile : Some ( profile. clone ( ) ) ,
885+ name : Some ( name. to_string ( ) ) ,
886+ id : Some ( id. to_string ( ) ) ,
887+ is_relay : true ,
888+ para_id : None ,
889+ default_bootnode : Some ( default_bootnode) ,
890+ chain_type : Some ( chain_type. clone ( ) ) ,
891+ features : "" . to_string ( ) ,
892+ chain : Some ( "local" . to_string ( ) ) ,
893+ relay : None ,
894+ protocol_id : Some ( protocol_id. to_string ( ) ) ,
895+ properties : Some ( properties. to_string ( ) ) ,
896+ skip_build : true ,
897+ genesis_state : Some ( genesis_state) ,
898+ genesis_code : Some ( genesis_code) ,
899+ deterministic : Some ( deterministic) ,
900+ package : Some ( package. to_string ( ) ) ,
901+ runtime_dir : Some ( runtime_dir. clone ( ) ) ,
902+ } ,
903+ Some ( "local" . to_string ( ) ) ,
904+ ) ,
878905 ] {
879906 let mut cli = MockCli :: new ( ) ;
880907 // If no flags are provided.
@@ -919,11 +946,9 @@ mod tests {
919946 let build_spec = build_spec_cmd. configure_build_spec ( & mut cli) . await ?;
920947 assert_eq ! ( build_spec. chain, chain) ;
921948 assert_eq ! ( build_spec. output_file, PathBuf :: from( output_file) ) ;
922- assert_eq ! ( build_spec. para_id, para_id) ;
923949 assert_eq ! ( build_spec. profile, profile) ;
924950 assert_eq ! ( build_spec. default_bootnode, default_bootnode) ;
925951 assert_eq ! ( build_spec. chain_type, chain_type) ;
926- assert_eq ! ( build_spec. relay, relay) ;
927952 assert_eq ! ( build_spec. protocol_id, protocol_id) ;
928953 assert_eq ! ( build_spec. genesis_state, genesis_state) ;
929954 assert_eq ! ( build_spec. genesis_code, genesis_code) ;
@@ -938,6 +963,14 @@ mod tests {
938963 assert_eq ! ( build_spec. id, None ) ;
939964 }
940965
966+ if build. is_relay {
967+ assert_eq ! ( build_spec. para_id, None ) ;
968+ assert_eq ! ( build_spec. relay, None ) ;
969+ } else {
970+ assert_eq ! ( build_spec. para_id, Some ( para_id) ) ;
971+ assert_eq ! ( build_spec. relay, Some ( relay) ) ;
972+ }
973+
941974 cli. verify ( ) ?;
942975 }
943976 Ok ( ( ) )
@@ -975,11 +1008,12 @@ mod tests {
9751008 chain : Some ( chain_spec_path. to_string_lossy ( ) . to_string ( ) ) ,
9761009 ..Default :: default ( )
9771010 } ,
978- // All flags used.
1011+ // All flags used. Parachain
9791012 BuildSpecCommand {
9801013 path : path. clone ( ) ,
9811014 output_file : Some ( PathBuf :: from ( output_file) ) ,
9821015 profile : Some ( profile. clone ( ) ) ,
1016+ is_relay : false ,
9831017 para_id : Some ( para_id) ,
9841018 default_bootnode : None ,
9851019 chain_type : Some ( chain_type. clone ( ) ) ,
@@ -997,6 +1031,29 @@ mod tests {
9971031 package : Some ( package. to_string ( ) ) ,
9981032 runtime_dir : Some ( runtime_dir. clone ( ) ) ,
9991033 } ,
1034+ // All flags used. Relay
1035+ BuildSpecCommand {
1036+ path : path. clone ( ) ,
1037+ output_file : Some ( PathBuf :: from ( output_file) ) ,
1038+ profile : Some ( profile. clone ( ) ) ,
1039+ is_relay : true ,
1040+ para_id : None ,
1041+ default_bootnode : None ,
1042+ chain_type : Some ( chain_type. clone ( ) ) ,
1043+ features : "" . to_string ( ) ,
1044+ name : Some ( name. to_string ( ) ) ,
1045+ id : Some ( id. to_string ( ) ) ,
1046+ chain : Some ( chain_spec_path. to_string_lossy ( ) . to_string ( ) ) ,
1047+ relay : None ,
1048+ protocol_id : Some ( protocol_id. to_string ( ) ) ,
1049+ properties : Some ( properties. to_string ( ) ) ,
1050+ skip_build : true ,
1051+ genesis_state : None ,
1052+ genesis_code : None ,
1053+ deterministic : None ,
1054+ package : Some ( package. to_string ( ) ) ,
1055+ runtime_dir : Some ( runtime_dir. clone ( ) ) ,
1056+ } ,
10001057 ] {
10011058 let mut cli = MockCli :: new ( ) . expect_confirm (
10021059 "An existing chain spec file is provided. Do you want to make additional changes to it?" ,
@@ -1079,9 +1136,9 @@ mod tests {
10791136 }
10801137 let build_spec = build_spec_cmd. configure_build_spec ( & mut cli) . await ?;
10811138 if !changes && no_flags_used {
1082- assert_eq ! ( build_spec. para_id, 2000 ) ;
1139+ assert_eq ! ( build_spec. para_id, Some ( 2000 ) ) ;
10831140 assert_eq ! ( build_spec. chain_type, Development ) ;
1084- assert_eq ! ( build_spec. relay, PaseoLocal ) ;
1141+ assert_eq ! ( build_spec. relay, Some ( PaseoLocal ) ) ;
10851142 assert_eq ! ( build_spec. protocol_id, "my-protocol" ) ;
10861143 assert_eq ! ( build_spec. name, None ) ;
10871144 assert_eq ! ( build_spec. id, None ) ;
@@ -1091,27 +1148,32 @@ mod tests {
10911148 assert_eq ! ( build_spec. package, DEFAULT_PACKAGE ) ;
10921149 assert_eq ! ( build_spec. runtime_dir, None ) ;
10931150 } else if changes && no_flags_used {
1094- assert_eq ! ( build_spec. para_id, para_id) ;
1151+ assert_eq ! ( build_spec. para_id, Some ( para_id) ) ;
10951152 assert_eq ! ( build_spec. profile, profile) ;
10961153 assert_eq ! ( build_spec. default_bootnode, default_bootnode) ;
10971154 assert_eq ! ( build_spec. chain_type, chain_type) ;
10981155 assert_eq ! ( build_spec. name, None ) ;
10991156 assert_eq ! ( build_spec. id, None ) ;
1100- assert_eq ! ( build_spec. relay, relay) ;
1157+ assert_eq ! ( build_spec. relay, Some ( relay) ) ;
11011158 assert_eq ! ( build_spec. protocol_id, protocol_id) ;
11021159 assert_eq ! ( build_spec. genesis_state, genesis_state) ;
11031160 assert_eq ! ( build_spec. genesis_code, genesis_code) ;
11041161 assert_eq ! ( build_spec. deterministic, deterministic) ;
11051162 assert_eq ! ( build_spec. package, package) ;
11061163 assert_eq ! ( build_spec. runtime_dir, Some ( runtime_dir. clone( ) ) ) ;
11071164 } else if !no_flags_used {
1108- assert_eq ! ( build_spec. para_id, para_id) ;
11091165 assert_eq ! ( build_spec. profile, profile) ;
11101166 assert ! ( !build_spec. default_bootnode) ;
11111167 assert_eq ! ( build_spec. chain_type, chain_type) ;
11121168 assert_eq ! ( build_spec. name, Some ( name. to_string( ) ) ) ;
11131169 assert_eq ! ( build_spec. id, Some ( id. to_string( ) ) ) ;
1114- assert_eq ! ( build_spec. relay, relay) ;
1170+ if build_spec. is_relay {
1171+ assert_eq ! ( build_spec. para_id, None ) ;
1172+ assert_eq ! ( build_spec. relay, None ) ;
1173+ } else {
1174+ assert_eq ! ( build_spec. para_id, Some ( para_id) ) ;
1175+ assert_eq ! ( build_spec. relay, Some ( relay) ) ;
1176+ }
11151177 assert_eq ! ( build_spec. protocol_id, protocol_id) ;
11161178 assert ! ( !build_spec. genesis_state) ;
11171179 assert ! ( !build_spec. genesis_code) ;
0 commit comments