@@ -483,3 +483,79 @@ fn storage_proof_to_raw_json(storage_proof: &sp_state_machine::StorageProof) ->
483483 )
484484 . to_string ( )
485485}
486+
487+ #[ cfg( test) ]
488+ mod tests {
489+ use super :: * ;
490+ use clap:: Parser ;
491+
492+ #[ derive( Parser ) ]
493+ struct TestCli {
494+ #[ command( subcommand) ]
495+ state : State ,
496+ }
497+
498+ #[ test]
499+ fn uri_repeated_flags ( ) {
500+ let cli = TestCli :: parse_from ( [
501+ "test" ,
502+ "live" ,
503+ "--uri" ,
504+ "ws://localhost:9999" ,
505+ "--uri" ,
506+ "ws://localhost:9998" ,
507+ ] ) ;
508+ match cli. state {
509+ State :: Live ( live) => {
510+ assert_eq ! ( live. uri, vec![ "ws://localhost:9999" , "ws://localhost:9998" ] ) ;
511+ }
512+ _ => panic ! ( "expected Live variant" ) ,
513+ }
514+ }
515+
516+ #[ test]
517+ fn uri_comma_separated ( ) {
518+ let cli = TestCli :: parse_from ( [
519+ "test" ,
520+ "live" ,
521+ "--uri" ,
522+ "ws://localhost:9999,ws://localhost:9998" ,
523+ ] ) ;
524+ match cli. state {
525+ State :: Live ( live) => {
526+ assert_eq ! ( live. uri, vec![ "ws://localhost:9999" , "ws://localhost:9998" ] ) ;
527+ }
528+ _ => panic ! ( "expected Live variant" ) ,
529+ }
530+ }
531+
532+ #[ test]
533+ fn uri_single_value ( ) {
534+ let cli = TestCli :: parse_from ( [ "test" , "live" , "--uri" , "wss://rpc.polkadot.io:443" ] ) ;
535+ match cli. state {
536+ State :: Live ( live) => {
537+ assert_eq ! ( live. uri, vec![ "wss://rpc.polkadot.io:443" ] ) ;
538+ }
539+ _ => panic ! ( "expected Live variant" ) ,
540+ }
541+ }
542+
543+ #[ test]
544+ fn uri_positional_not_swallowed ( ) {
545+ let cli = TestCli :: parse_from ( [
546+ "test" ,
547+ "live" ,
548+ "--uri" ,
549+ "ws://localhost:9999" ,
550+ "--pallet" ,
551+ "System" ,
552+ ] ) ;
553+ match cli. state {
554+ State :: Live ( live) => {
555+ assert_eq ! ( live. uri, vec![ "ws://localhost:9999" ] ) ;
556+ assert_eq ! ( live. pallet, vec![ "System" ] ) ;
557+ }
558+ _ => panic ! ( "expected Live variant" ) ,
559+ }
560+ }
561+ }
0 commit comments