File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed
Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -262,13 +262,13 @@ fn app() -> Command {
262262 - start_date: time when the node was started\n \
263263 - uptime: uptime in the format 'XX days XX hours XX minutes'\n ")
264264 . num_args ( 1 )
265- // .validator (|m| {
266- // if m.len() > BOOSTRAP_SERVER_MAX_MOTD_LENGTH {
267- // Err(format!("Message of the day must not be longer than {} bytes", BOOSTRAP_SERVER_MAX_MOTD_LENGTH))
268- // } else {
269- // Ok(())
270- // }
271- // })
265+ . value_parser ( |m : & str | {
266+ if m. len ( ) > BOOSTRAP_SERVER_MAX_MOTD_LENGTH {
267+ Err ( format ! ( "Message of the day must not be longer than {} bytes" , BOOSTRAP_SERVER_MAX_MOTD_LENGTH ) )
268+ } else {
269+ Ok ( m . to_string ( ) )
270+ }
271+ } )
272272 . default_value ( "This is tox-rs" ) )
273273 . arg ( Arg :: new ( "lan-discovery" )
274274 . long ( "lan-discovery" )
@@ -545,6 +545,21 @@ mod tests {
545545 assert_eq ! ( config. motd, motd) ;
546546 }
547547
548+ #[ test]
549+ fn args_motd_too_long ( ) {
550+ let motd = "x" . repeat ( BOOSTRAP_SERVER_MAX_MOTD_LENGTH + 1 ) ;
551+ let matches = app ( ) . try_get_matches_from ( vec ! [
552+ "tox-node" ,
553+ "--keys-file" ,
554+ "./keys" ,
555+ "--udp-address" ,
556+ "127.0.0.1:33445" ,
557+ "--motd" ,
558+ & motd,
559+ ] ) ;
560+ assert ! ( matches. is_err( ) ) ;
561+ }
562+
548563 #[ test]
549564 fn args_lan_discovery ( ) {
550565 let matches = app ( ) . get_matches_from ( vec ! [
You can’t perform that action at this time.
0 commit comments