From 1315141b1b5539489dcb6b2975a02821c1ab261b Mon Sep 17 00:00:00 2001 From: wesrer Date: Mon, 1 Jun 2020 12:08:55 +0000 Subject: [PATCH] made suggested changes, and removed some deprecated flags and options --- parity/cli/args.rs | 106 +++++++++++++---------------------- parity/cli/config.rs | 15 ++--- parity/cli/globals.rs | 17 ++---- parity/cli/subcommands.rs | 19 ------- parity/cli/tests/test_cli.rs | 4 +- parity/test_configuration.rs | 72 ++++++++++++------------ 6 files changed, 90 insertions(+), 143 deletions(-) diff --git a/parity/cli/args.rs b/parity/cli/args.rs index 82cb44b4af3..7b17eb4ed0c 100644 --- a/parity/cli/args.rs +++ b/parity/cli/args.rs @@ -138,7 +138,6 @@ pub struct Args { pub arg_jsonrpc_interface: String, pub arg_jsonrpc_apis: String, pub arg_jsonrpc_hosts: String, - pub arg_jsonrpc_threads: Option, pub arg_jsonrpc_server_threads: Option, pub arg_jsonrpc_cors: String, pub arg_jsonrpc_max_payload: Option, @@ -282,7 +281,7 @@ impl Args { let (default_config, fallback_config) = Args::generate_default_configuration(default_config_path, fallback_config_path)?; - args.from_cli(raw_input, default_config, fallback_config)?; + args.absorb_cli(raw_input, default_config, fallback_config)?; Ok(args) } @@ -294,14 +293,17 @@ impl Args { globals.convenience.config_generate = None; if let Some(path) = &config_generate { - let current_flags = match toml::to_string(globals) { - Ok(x) => x, - Err(_) => return Err(ArgsError::ConfigWriteError("Failed to generate valid config toml from current flags. Please report a bug if this error persists.".to_owned())), - }; - - if let Err(_) = fs::write(&path, current_flags) { - return Err(ArgsError::ConfigParseError(format!("Failed to write config to given file path: {}. Please try again with a valid path and config name.", &path))); - }; + let current_flags = toml::to_string(globals).map_err(|e| { + ArgsError::ConfigWriteError(format!( + "Failed to generate valid config toml from current flags: {}.Please report a bug if this error persists.", e + )) + })?; + + fs::write(&path, current_flags).map_err(|_| { + ArgsError::ConfigParseError(format!( + "Failed to write config to given file path {}. Please try again with a valid path and config name.", &path + )) + })?; } Ok(()) } @@ -314,40 +316,35 @@ impl Args { let default_config_file:String = get_config(default_config_path)?; let fallback_config_file:String = get_config(fallback_config_path)?; - let default_config: Globals = match toml::from_str(&default_config_file) { - Ok(x) => x, - Err(e) => { - return Err(ArgsError::ConfigParseError(format!( - "Failure to parse config file: {}, error: {}", - default_config_path, e - ))) - } - }; - let fallback_config: Globals = match toml::from_str(&fallback_config_file) { - Ok(x) => x, - Err(_) => { - return Err(ArgsError::ConfigParseError(format!( - "Failure to parse config file: {}", - fallback_config_path - ))) - } - }; + let default_config: Globals = toml::from_str(&default_config_file).map_err(|e| { + ArgsError::ConfigParseError(format!( + "Failure to parse config file: {}, error: {}", + default_config_path, e + )) + })?; + + let fallback_config: Globals = toml::from_str(&fallback_config_file).map_err(|e| { + ArgsError::ConfigParseError(format!( + "Failure to parse config file {}: {}", + fallback_config_path, e + )) + })?; Ok((default_config, fallback_config)) } - pub fn from_cli( + pub fn absorb_cli( &mut self, cli_args: ArgsInput, default_globals: Globals, fallback_globals: Globals, ) -> Result<(), ArgsError> { - self.from_subcommands(&cli_args)?; - self.from_globals(cli_args, default_globals, fallback_globals)?; + self.absorb_subcommands(&cli_args)?; + self.absorb_globals(cli_args, default_globals, fallback_globals)?; Ok(()) } - fn from_subcommands(&mut self, cli_args: &ArgsInput) -> Result<(), ArgsError> { + fn absorb_subcommands(&mut self, cli_args: &ArgsInput) -> Result<(), ArgsError> { match &cli_args.subcommands { None => {} Some(subcommand) => match &subcommand { @@ -425,13 +422,6 @@ impl Args { } } } - SubCommands::Tools(t) => { - self.cmd_tools = true; - self.cmd_tools_hash = true; - - let Tools::Hash { file } = t; - self.arg_tools_hash_file = (*file).clone(); - } SubCommands::Restore(r) => { self.cmd_restore = true; self.arg_restore_file = r.file.clone(); @@ -456,44 +446,31 @@ impl Args { SubCommands::ExportHardcodedSync => { self.cmd_export_hardcoded_sync = true; } - SubCommands::Dapp(dapp) => { - self.cmd_dapp = true; - self.arg_dapp_path = dapp.path.clone(); - } + }, } Ok(()) } fn select_value(raw: Option, default: Option, fallback: Option) -> T { - match (raw, default, fallback) { - (Some(x), _, _) => x, - (None, Some(x), _) => x, - (None, None, Some(x)) => x, - _ => todo!(), // FIXME: this case should never arise, but we need to fail gracefully if it does - } + raw.or(default).or(fallback).expect("Value is always present, at least in fallback") } fn select_option(raw: Option, default: Option, fallback: Option) -> Option { - match (&raw, &default, &fallback) { - (None, None, Some(_)) => fallback, - (None, Some(_), _) => default, - // Handles the cases where there was a raw value, so we can ignore everything else - _ => raw, - } + raw.or(default).or(fallback) } - fn from_globals( + fn absorb_globals( &mut self, cli_args: ArgsInput, defaults: Globals, fallback: Globals, ) -> Result<(), ArgsError> { - self.flags_from_globals(&cli_args, &defaults, &fallback); - self.options_from_globals(cli_args, defaults, fallback); + self.absorb_global_flags(&cli_args, &defaults, &fallback); + self.absorb_global_options(cli_args, defaults, fallback); if let (Some(min_peers), Some(max_peers)) = (self.arg_min_peers, self.arg_max_peers) { - if (max_peers >= min_peers).not() { + if (max_peers < min_peers){ return Err(ArgsError::PeerConfigurationError( "max-peers need to be greater than or equal to min-peers".to_owned(), )); @@ -502,12 +479,12 @@ impl Args { Ok(()) } - fn options_from_globals(&mut self, cli_args: ArgsInput, defaults: Globals, fallback: Globals) { + fn absorb_global_options(&mut self, cli_args: ArgsInput, defaults: Globals, fallback: Globals) { // Unnatural cases self.arg_ipc_path = Args::select_value( cli_args.globals.ipc.ipc_path, - IPCOptions::ipc_path_default(), + Some(IPCOptions::ipc_path_default()), None, // We don't care about fallback in this case, since the previous operation is infallible ); self.arg_password = cli_args.globals.account.password; @@ -715,11 +692,6 @@ impl Args { defaults.http_json_rpc.jsonrpc_hosts, fallback.http_json_rpc.jsonrpc_hosts, ); - self.arg_jsonrpc_threads = Args::select_option( - cli_args.globals.http_json_rpc.jsonrpc_threads, - defaults.http_json_rpc.jsonrpc_threads, - fallback.http_json_rpc.jsonrpc_threads, - ); self.arg_jsonrpc_server_threads = Args::select_option( cli_args.globals.http_json_rpc.jsonrpc_server_threads, defaults.http_json_rpc.jsonrpc_server_threads, @@ -1114,7 +1086,7 @@ impl Args { ); } - fn flags_from_globals(&mut self, cli_args: &ArgsInput, defaults: &Globals, fallback: &Globals) { + fn absorb_global_flags(&mut self, cli_args: &ArgsInput, defaults: &Globals, fallback: &Globals) { self.arg_enable_signing_queue = cli_args.globals.account.enable_signing_queue || defaults.account.enable_signing_queue || fallback.account.enable_signing_queue; diff --git a/parity/cli/config.rs b/parity/cli/config.rs index d63f8e5296e..ac6b0723921 100644 --- a/parity/cli/config.rs +++ b/parity/cli/config.rs @@ -6,11 +6,12 @@ use rust_embed::RustEmbed; struct Config; pub fn get_config(config_name: &str) -> Result { - match Config::get(config_name) { - Some(x) => Ok((std::str::from_utf8(x.as_ref()).unwrap()).to_owned()), - None => Err(ArgsError::ConfigReadError(format!( - "Failure to read config file: {}", - config_name - ))), - } + Config::get(config_name) + .ok_or_else(|| "does not exist".to_owned()) + // .and_then(|x| srt(x).map_err(|e| e.to_owned())) + .and_then(|x| String::from_utf8(x.to_vec()).map_err(|e| e.to_string())) + .map_err(|e| ArgsError::ConfigReadError(format!( + "Failure to read config file {}: {}", + config_name, e + ))) } diff --git a/parity/cli/globals.rs b/parity/cli/globals.rs index 1c4c5c9732c..56d75ce2750 100644 --- a/parity/cli/globals.rs +++ b/parity/cli/globals.rs @@ -261,7 +261,7 @@ pub struct PrivateTransactions { #[structopt( long = "private-signer", - long = "ACCOUNT", + name = "ACCOUNT", help = "Specify the account for signing public transaction created upon verified private transaction." )] pub private_signer: Option, @@ -457,11 +457,11 @@ pub struct IPCOptions { } impl IPCOptions { - pub fn ipc_path_default() -> Option { + pub fn ipc_path_default() -> String { if cfg!(windows) { - Some(r"\\.\pipe\jsonrpc.ipc".to_string()) + r"\\.\pipe\jsonrpc.ipc".to_owned() } else { - Some("$BASE/jsonrpc.ipc".to_string()) + "$BASE/jsonrpc.ipc".to_owned() } } } @@ -517,13 +517,6 @@ pub struct HTTP_JSON_RPC_Options { )] pub jsonrpc_hosts: Option, - #[structopt( - long = "jsonrpc-threads", - name = "JSONRPC_THREADS_NUM", - help = "DEPRECATED, DOES NOTHING" - )] - pub jsonrpc_threads: Option, - #[structopt( long = "jsonrpc-server-threads", name = "JSONRPC_SERVER_THREADS", @@ -633,7 +626,7 @@ pub struct WebsocketsOptions { #[structopt( help = "Maximum number of allowed concurrent WebSockets JSON-RPC connections.", - long = "ws=-connections", + long = "ws-connections", name = "WS_MAX_CONN" )] pub ws_max_connections: Option, diff --git a/parity/cli/subcommands.rs b/parity/cli/subcommands.rs index bcb509009f2..ea0322be1cf 100644 --- a/parity/cli/subcommands.rs +++ b/parity/cli/subcommands.rs @@ -20,13 +20,11 @@ pub enum SubCommands { Signer(Signer), Snapshots(Snapshots), Restore(Restore), - Tools(Tools), Db(Db), #[structopt( about = "Print the hashed light clients headers of the given --chain (default: mainnet) in a JSON format. To be used as hardcoded headers in a genesis file." )] ExportHardcodedSync, - Dapp(Dapp), } #[derive(StructOpt, Deserialize, Debug, Clone)] @@ -208,16 +206,6 @@ pub struct Restore { pub file: Option, } -#[derive(StructOpt, Deserialize, Debug, Clone)] -#[structopt(about = "Tools")] -pub enum Tools { - #[structopt(about = "Hash a file using the Keccak-256 algorithm")] - Hash { - #[structopt(name = "FILE")] - file: Option, - }, -} - #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Manage the Database representing the state of the blockchain on this system")] pub enum Db { @@ -233,10 +221,3 @@ pub enum Db { num: u32, }, } - -#[derive(StructOpt, Deserialize, Debug, Clone)] -#[structopt(about = "Manage Dapps")] -pub struct Dapp { - #[structopt(help = "Path to the dapps", name = "PATH")] - pub path: Option, -} diff --git a/parity/cli/tests/test_cli.rs b/parity/cli/tests/test_cli.rs index 4fc4f4079f0..0a3865fb5fc 100644 --- a/parity/cli/tests/test_cli.rs +++ b/parity/cli/tests/test_cli.rs @@ -34,7 +34,7 @@ fn test_overwrite_custom_config_with_raw_flags() { let (user_defaults, fallback) = Args::generate_default_configuration("test_config.toml", "config_default.toml").unwrap(); - resolved.from_cli(raw, user_defaults, fallback); + resolved.absorb_cli(raw, user_defaults, fallback); assert_eq!(resolved.arg_stratum_secret, Some("Changed".to_owned())); } @@ -50,7 +50,7 @@ fn test_not_accepting_min_peers_bigger_than_max_peers() { raw.globals.networking.min_peers = Some(50); raw.globals.networking.max_peers = Some(40); - let output = resolved.from_cli(raw, user_defaults, fallback); + let output = resolved.absorb_cli(raw, user_defaults, fallback); assert_eq!( output, diff --git a/parity/test_configuration.rs b/parity/test_configuration.rs index 46ee57a757e..96dd309160d 100644 --- a/parity/test_configuration.rs +++ b/parity/test_configuration.rs @@ -52,7 +52,7 @@ mod test_configuration{ #[test] fn test_subcommand_account_new() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_account = true; conf.cmd_account_new = true; @@ -81,7 +81,7 @@ mod test_configuration{ conf.cmd_account = true; conf.cmd_account_list = true; - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -103,7 +103,7 @@ mod test_configuration{ fn test_command_account_import() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_account = true; conf.cmd_account_import = true; @@ -127,7 +127,7 @@ mod test_configuration{ #[test] fn test_command_wallet_import() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_wallet = true; conf.cmd_wallet_import = true; @@ -155,7 +155,7 @@ mod test_configuration{ fn test_command_blockchain_import() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_import = true; conf.arg_import_file = Some("blockchain.json".to_owned()); @@ -191,7 +191,7 @@ mod test_configuration{ #[test] fn test_command_blockchain_export() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_export = true; conf.cmd_export_blocks = true; @@ -227,7 +227,7 @@ mod test_configuration{ #[test] fn test_command_state_export() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_export = true; conf.cmd_export_state = true; @@ -269,7 +269,7 @@ mod test_configuration{ fn test_command_blockchain_export_with_custom_format() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_export = true; conf.cmd_export_blocks = true; @@ -307,7 +307,7 @@ mod test_configuration{ fn test_command_signer_new_token() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.cmd_signer = true; conf.cmd_signer_new_token = true; @@ -341,7 +341,7 @@ mod test_configuration{ #[test] fn test_ws_max_connections() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.arg_ws_max_connections = 1; @@ -358,7 +358,7 @@ mod test_configuration{ #[test] fn test_run_cmd() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -441,7 +441,7 @@ mod test_configuration{ // setting up 2 separate configs let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); // default config + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); // default config let mut conf2 = conf0.clone(); conf2.arg_tx_queue_strategy = "gas_price".to_owned(); // modified config @@ -463,7 +463,7 @@ mod test_configuration{ #[test] fn should_fail_on_force_reseal_and_reseal_min_period() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.arg_chain = "dev".to_owned(); conf.flag_force_sealing = true; @@ -479,7 +479,7 @@ mod test_configuration{ #[test] fn should_parse_updater_options() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); conf0.arg_auto_update = "all".to_owned(); conf0.arg_auto_update_delay = 300; @@ -504,7 +504,7 @@ mod test_configuration{ #[test] fn should_parse_network_settings() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); conf0.arg_identity = "testname".to_owned(); conf0.arg_chain = "goerli".to_owned(); @@ -538,7 +538,7 @@ mod test_configuration{ } let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf2 = conf0.clone(); @@ -557,7 +557,7 @@ mod test_configuration{ fn should_parse_rpc_hosts() { // given let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); let mut conf1 = conf0.clone(); let mut conf2 = conf0.clone(); @@ -590,7 +590,7 @@ mod test_configuration{ #[test] fn should_respect_only_min_peers_and_default() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.arg_min_peers = Some(5); @@ -610,7 +610,7 @@ mod test_configuration{ #[test] fn should_respect_only_min_peers_and_greater_than_default() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); conf.arg_min_peers = Some(500); @@ -630,7 +630,7 @@ mod test_configuration{ #[test] fn should_parse_secretstore_cors() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); let mut conf1 = conf0.clone(); let mut conf2 = conf0.clone(); @@ -659,7 +659,7 @@ mod test_configuration{ #[test] fn ensures_sane_http_settings() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); conf0.arg_jsonrpc_server_threads = Some(0); conf0.arg_jsonrpc_max_payload = Some(0); @@ -678,7 +678,7 @@ mod test_configuration{ fn jsonrpc_threading_defaults() { let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); assert_eq!(conf.arg_jsonrpc_server_threads, Some(4)); } @@ -694,7 +694,7 @@ mod test_configuration{ "config_default.toml" ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -721,7 +721,7 @@ mod test_configuration{ "config_default.toml" ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -754,7 +754,7 @@ mod test_configuration{ "config_default.toml" ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -780,7 +780,7 @@ mod test_configuration{ "config_default.toml" ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -812,7 +812,7 @@ mod test_configuration{ "config_default.toml" ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -849,7 +849,7 @@ mod test_configuration{ "config_default.toml" ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.absorb_cli(raw, user_defaults, fallback).unwrap(); let conf = Configuration { args: conf, @@ -866,7 +866,7 @@ mod test_configuration{ #[test] fn test_identity_arg() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); conf0.arg_identity = "Somebody".to_owned(); @@ -887,7 +887,7 @@ mod test_configuration{ fn should_apply_ports_shift() { // give let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); let mut conf1 = conf0.clone(); @@ -927,7 +927,7 @@ mod test_configuration{ fn should_resolve_external_nat_hosts() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); let mut conf1 = conf0.clone(); let mut conf2 = conf0.clone(); @@ -982,7 +982,7 @@ mod test_configuration{ #[test] fn should_expose_all_servers() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); conf0.flag_unsafe_expose = true; @@ -1004,7 +1004,7 @@ mod test_configuration{ fn allow_ips() { let (mut all, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - all.from_cli(raw, user_defaults, fallback).unwrap(); + all.absorb_cli(raw, user_defaults, fallback).unwrap(); let mut private = all.clone(); let mut block_custom = all.clone(); @@ -1084,7 +1084,7 @@ mod test_configuration{ use std::path; let (mut std, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - std.from_cli(raw, user_defaults, fallback).unwrap(); + std.absorb_cli(raw, user_defaults, fallback).unwrap(); let mut base = std.clone(); base.arg_base_path = Some("/test".to_owned()); @@ -1107,7 +1107,7 @@ mod test_configuration{ fn should_respect_only_max_peers_and_default() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); conf0.arg_max_peers = Some(50); @@ -1127,7 +1127,7 @@ mod test_configuration{ #[test] fn should_respect_only_max_peers_less_than_default() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + conf0.absorb_cli(raw, user_defaults, fallback).unwrap(); conf0.arg_max_peers = Some(5);