Skip to content

Commit

Permalink
Merge branch 'master' into GH-728
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshg6 committed Oct 23, 2023
2 parents a39a0c8 + b2d0b07 commit 4ced510
Show file tree
Hide file tree
Showing 99 changed files with 5,556 additions and 3,138 deletions.
10 changes: 4 additions & 6 deletions automap/src/comm_layer/pcp_pmp_common/macos_specific.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) 2019-2021, MASQ (https://masq.ai) and/or its affiliates. All rights reserved.

#![cfg(target_os = "macos")]

use crate::comm_layer::pcp_pmp_common::FindRoutersCommand;
use crate::comm_layer::AutomapError;
use masq_lib::utils::to_string;
use std::net::IpAddr;
use std::str::FromStr;

Expand All @@ -13,13 +15,9 @@ pub fn macos_find_routers(command: &dyn FindRoutersCommand) -> Result<Vec<IpAddr
};
let addresses = output
.split('\n')
.map(|line_ref| line_ref.to_string())
.map(to_string)
.filter(|line| line.contains("gateway:"))
.map(|line| {
line.split(": ")
.map(|piece| piece.to_string())
.collect::<Vec<String>>()
})
.map(|line| line.split(": ").map(to_string).collect::<Vec<String>>())
.filter(|pieces| pieces.len() > 1)
.map(|pieces| IpAddr::from_str(&pieces[1]).expect("Bad syntax from route -n get default"))
.collect::<Vec<IpAddr>>();
Expand Down
4 changes: 2 additions & 2 deletions masq/src/command_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod tests {
use masq_lib::messages::UiShutdownRequest;
use masq_lib::messages::{ToMessageBody, UiCheckPasswordResponse, UiUndeliveredFireAndForget};
use masq_lib::test_utils::mock_websockets_server::MockWebSocketsServer;
use masq_lib::utils::{find_free_port, running_test};
use masq_lib::utils::{find_free_port, running_test, to_string};
use std::thread;
use std::time::Duration;

Expand Down Expand Up @@ -210,7 +210,7 @@ mod tests {
fn whole_message() -> String {
TameCommand::MESSAGE_IN_PIECES
.iter()
.map(|str| str.to_string())
.map(to_string)
.collect()
}
}
Expand Down
6 changes: 2 additions & 4 deletions masq/src/commands/change_password_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use clap::{App, Arg, SubCommand};
use masq_lib::messages::{
UiChangePasswordRequest, UiChangePasswordResponse, UiNewPasswordBroadcast,
};
use masq_lib::{implement_as_any, short_writeln};
#[cfg(test)]
use std::any::Any;
use masq_lib::{as_any_in_trait_impl, short_writeln};
use std::io::Write;

#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -81,7 +79,7 @@ impl Command for ChangePasswordCommand {
Ok(())
}

implement_as_any!();
as_any_in_trait_impl!();
}

pub fn change_password_subcommand() -> App<'static, 'static> {
Expand Down
9 changes: 4 additions & 5 deletions masq/src/commands/check_password_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use crate::commands::commands_common::{
transaction, Command, CommandError, STANDARD_COMMAND_TIMEOUT_MILLIS,
};
use clap::{App, Arg, SubCommand};
use masq_lib::implement_as_any;
use masq_lib::as_any_in_trait_impl;
use masq_lib::messages::{UiCheckPasswordRequest, UiCheckPasswordResponse};
use masq_lib::short_writeln;
#[cfg(test)]
use std::any::Any;
use masq_lib::utils::to_string;

#[derive(Debug, PartialEq, Eq)]
pub struct CheckPasswordCommand {
Expand Down Expand Up @@ -52,7 +51,7 @@ impl Command for CheckPasswordCommand {
Ok(())
}

implement_as_any!();
as_any_in_trait_impl!();
}

impl CheckPasswordCommand {
Expand All @@ -62,7 +61,7 @@ impl CheckPasswordCommand {
Err(e) => return Err(format!("{}", e)),
};
Ok(Self {
db_password_opt: matches.value_of("db-password").map(|r| r.to_string()),
db_password_opt: matches.value_of("db-password").map(to_string),
})
}
}
Expand Down
9 changes: 4 additions & 5 deletions masq/src/commands/configuration_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ use crate::commands::commands_common::{
dump_parameter_line, transaction, Command, CommandError, STANDARD_COMMAND_TIMEOUT_MILLIS,
};
use clap::{App, Arg, SubCommand};
use masq_lib::as_any_in_trait_impl;
use masq_lib::constants::NODE_NOT_RUNNING_ERROR;
use masq_lib::implement_as_any;
use masq_lib::messages::{UiConfigurationRequest, UiConfigurationResponse};
use masq_lib::short_writeln;
#[cfg(test)]
use std::any::Any;
use masq_lib::utils::to_string;
use std::fmt::{Debug, Display};
use std::io::Write;
use std::iter::once;
Expand Down Expand Up @@ -65,7 +64,7 @@ impl Command for ConfigurationCommand {
}
}

implement_as_any!();
as_any_in_trait_impl!();
}

impl ConfigurationCommand {
Expand All @@ -76,7 +75,7 @@ impl ConfigurationCommand {
};

Ok(ConfigurationCommand {
db_password: matches.value_of("db-password").map(|s| s.to_string()),
db_password: matches.value_of("db-password").map(to_string),
})
}

Expand Down
6 changes: 2 additions & 4 deletions masq/src/commands/connection_status_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ use crate::commands::commands_common::{
transaction, Command, CommandError, STANDARD_COMMAND_TIMEOUT_MILLIS,
};
use clap::{App, SubCommand};
use masq_lib::as_any_in_trait_impl;
use masq_lib::constants::NODE_NOT_RUNNING_ERROR;
use masq_lib::implement_as_any;
use masq_lib::messages::{
UiConnectionStage, UiConnectionStatusRequest, UiConnectionStatusResponse,
};
use masq_lib::short_writeln;
#[cfg(test)]
use std::any::Any;
use std::fmt::Debug;

#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -64,7 +62,7 @@ impl Command for ConnectionStatusCommand {
}
}

implement_as_any!();
as_any_in_trait_impl!();
}

impl ConnectionStatusCommand {
Expand Down
3 changes: 2 additions & 1 deletion masq/src/commands/financials_command/pretty_print_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub(in crate::commands::financials_command) mod restricted {
use masq_lib::constants::WALLET_ADDRESS_LENGTH;
use masq_lib::messages::{UiPayableAccount, UiReceivableAccount};
use masq_lib::short_writeln;
use masq_lib::utils::to_string;
use std::fmt::{Debug, Display};
use std::io::Write;
use thousands::Separable;
Expand Down Expand Up @@ -163,7 +164,7 @@ pub(in crate::commands::financials_command) mod restricted {

fn prepare_headings_of_records(is_gwei: bool) -> (HeadingsHolder, HeadingsHolder) {
fn to_owned_strings(words: Vec<&str>) -> Vec<String> {
words.iter().map(|str| str.to_string()).collect()
words.iter().map(to_string).collect()
}
let balance = gwei_or_masq_balance(is_gwei);
(
Expand Down
15 changes: 6 additions & 9 deletions masq/src/commands/generate_wallets_command.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
// Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved.

#[cfg(test)]
use std::any::Any;

use crate::command_context::CommandContext;
use crate::commands::commands_common::{
transaction, Command, CommandError, STANDARD_COMMAND_TIMEOUT_MILLIS,
};
use clap::{App, Arg, SubCommand};
use lazy_static::lazy_static;
use masq_lib::implement_as_any;
use masq_lib::as_any_in_trait_impl;
use masq_lib::messages::{UiGenerateSeedSpec, UiGenerateWalletsRequest, UiGenerateWalletsResponse};
use masq_lib::short_writeln;
use masq_lib::utils::DEFAULT_CONSUMING_DERIVATION_PATH;
use masq_lib::utils::DEFAULT_EARNING_DERIVATION_PATH;
use masq_lib::utils::{to_string, DEFAULT_CONSUMING_DERIVATION_PATH};

lazy_static! {
static ref CONSUMING_PATH_HELP: String = format!(
Expand Down Expand Up @@ -85,8 +82,8 @@ impl GenerateWalletsCommand {
Err(e) => return Err(format!("{}", e)),
};

let consuming_path_opt = matches.value_of("consuming-path").map(|p| p.to_string());
let earning_path_opt = matches.value_of("earning-path").map(|p| p.to_string());
let consuming_path_opt = matches.value_of("consuming-path").map(to_string);
let earning_path_opt = matches.value_of("earning-path").map(to_string);
let seed_spec_opt = if consuming_path_opt.is_some() || earning_path_opt.is_some() {
Some(SeedSpec {
word_count: matches
Expand All @@ -99,7 +96,7 @@ impl GenerateWalletsCommand {
.value_of("language")
.expect("language not properly defaulted")
.to_string(),
passphrase_opt: matches.value_of("passphrase").map(|s| s.to_string()),
passphrase_opt: matches.value_of("passphrase").map(to_string),
})
} else {
None
Expand Down Expand Up @@ -168,7 +165,7 @@ impl Command for GenerateWalletsCommand {
Ok(())
}

implement_as_any!();
as_any_in_trait_impl!();
}

pub fn generate_wallets_subcommand() -> App<'static, 'static> {
Expand Down
13 changes: 6 additions & 7 deletions masq/src/commands/recover_wallets_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ use crate::commands::commands_common::{
};
use clap::{App, Arg, ArgGroup, SubCommand};
use itertools::{Either, Itertools};
use masq_lib::implement_as_any;
use masq_lib::as_any_in_trait_impl;
use masq_lib::messages::{UiRecoverSeedSpec, UiRecoverWalletsRequest, UiRecoverWalletsResponse};
use masq_lib::short_writeln;
#[cfg(test)]
use std::any::Any;
use masq_lib::utils::to_string;

#[derive(Debug, PartialEq, Eq)]
pub struct SeedSpec {
Expand All @@ -36,12 +35,12 @@ impl RecoverWalletsCommand {

let mnemonic_phrase_opt = matches
.value_of("mnemonic-phrase")
.map(|mpv| mpv.split(' ').map(|x| x.to_string()).collect_vec());
.map(|mpv| mpv.split(' ').map(to_string).collect_vec());
let language = matches
.value_of("language")
.expect("language is not properly defaulted by clap")
.to_string();
let passphrase_opt = matches.value_of("passphrase").map(|mp| mp.to_string());
let passphrase_opt = matches.value_of("passphrase").map(to_string);
let seed_spec_opt = mnemonic_phrase_opt.map(|mnemonic_phrase| SeedSpec {
mnemonic_phrase,
language,
Expand Down Expand Up @@ -121,7 +120,7 @@ impl Command for RecoverWalletsCommand {
Ok(())
}

implement_as_any!();
as_any_in_trait_impl!();
}

const RECOVER_WALLETS_ABOUT: &str =
Expand Down Expand Up @@ -340,7 +339,7 @@ mod tests {
db_password: "password".to_string(),
seed_spec_opt: Some (SeedSpec {
mnemonic_phrase: "river message view churn potato cabbage craft luggage tape month observe obvious"
.split(" ").into_iter().map(|x| x.to_string()).collect(),
.split(" ").into_iter().map(to_string).collect(),
passphrase_opt: Some("booga".to_string()),
language: "English".to_string(),
}),
Expand Down
6 changes: 2 additions & 4 deletions masq/src/commands/set_configuration_command.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use crate::command_context::CommandContext;
use crate::commands::commands_common::{transaction, Command, CommandError};
use clap::{App, Arg, ArgGroup, SubCommand};
use masq_lib::implement_as_any;
use masq_lib::as_any_in_trait_impl;
use masq_lib::messages::{UiSetConfigurationRequest, UiSetConfigurationResponse};
use masq_lib::shared_schema::gas_price_arg;
use masq_lib::shared_schema::min_hops_arg;
use masq_lib::short_writeln;
use masq_lib::utils::ExpectValue;
#[cfg(test)]
use std::any::Any;

#[derive(Debug, PartialEq, Eq)]
pub struct SetConfigurationCommand {
Expand Down Expand Up @@ -55,7 +53,7 @@ impl Command for SetConfigurationCommand {
Ok(())
}

implement_as_any!();
as_any_in_trait_impl!();
}

const SET_CONFIGURATION_ABOUT: &str =
Expand Down
6 changes: 2 additions & 4 deletions masq/src/commands/setup_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ use crate::command_context::CommandContext;
use crate::commands::commands_common::{transaction, Command, CommandError};
use crate::terminal::terminal_interface::TerminalWrapper;
use clap::{value_t, App, SubCommand};
use masq_lib::as_any_in_trait_impl;
use masq_lib::constants::SETUP_ERROR;
use masq_lib::implement_as_any;
use masq_lib::messages::{
UiSetupBroadcast, UiSetupInner, UiSetupRequest, UiSetupRequestValue, UiSetupResponse,
UiSetupResponseValue, UiSetupResponseValueStatus,
};
use masq_lib::shared_schema::{data_directory_arg, shared_app};
use masq_lib::short_writeln;
use masq_lib::utils::{index_of_from, DATA_DIRECTORY_DAEMON_HELP};
#[cfg(test)]
use std::any::Any;
use std::fmt::Debug;
use std::io::Write;
use std::iter::Iterator;
Expand Down Expand Up @@ -53,7 +51,7 @@ impl Command for SetupCommand {
Err(e) => Err(e),
}
}
implement_as_any!();
as_any_in_trait_impl!();
}

impl SetupCommand {
Expand Down
6 changes: 2 additions & 4 deletions masq/src/commands/wallet_addresses_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use crate::commands::commands_common::{
};
use clap::{App, Arg, SubCommand};
use masq_lib::messages::{UiWalletAddressesRequest, UiWalletAddressesResponse};
use masq_lib::{implement_as_any, short_writeln};
#[cfg(test)]
use std::any::Any;
use masq_lib::{as_any_in_trait_impl, short_writeln};

#[derive(Debug, PartialEq, Eq)]
pub struct WalletAddressesCommand {
Expand Down Expand Up @@ -68,7 +66,7 @@ impl Command for WalletAddressesCommand {
);
Ok(())
}
implement_as_any!();
as_any_in_trait_impl!();
}

#[cfg(test)]
Expand Down
8 changes: 3 additions & 5 deletions masq/src/communications/broadcast_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@ use masq_lib::messages::{
};
use masq_lib::ui_gateway::MessageBody;
use masq_lib::utils::ExpectValue;
use masq_lib::{declare_as_any, implement_as_any, short_writeln};
use masq_lib::{as_any_in_trait, as_any_in_trait_impl, short_writeln};
use std::fmt::Debug;
use std::io::Write;
use std::thread;

use crate::notifications::connection_change_notification::ConnectionChangeNotification;
#[cfg(test)]
use std::any::Any;

pub trait BroadcastHandle: Send {
fn send(&self, message_body: MessageBody);
declare_as_any!();
as_any_in_trait!();
}

pub struct BroadcastHandleInactive;

impl BroadcastHandle for BroadcastHandleInactive {
//simply dropped (unless we find a better use for such a message)
fn send(&self, _message_body: MessageBody) {}
implement_as_any!();
as_any_in_trait_impl!();
}

pub struct BroadcastHandleGeneric {
Expand Down
5 changes: 3 additions & 2 deletions masq/src/non_interactive_clap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ fn handle_help_or_version_if_required<'a>(args: &[String]) -> ArgMatches<'a> {
mod tests {
use super::*;
use masq_lib::constants::DEFAULT_UI_PORT;
use masq_lib::utils::to_string;

#[test]
fn non_interactive_clap_real_produces_default_value_for_ui_port() {
let result = NonInteractiveClapReal.non_interactive_initial_clap_operations(
&vec!["masq", "setup", "--chain"]
.iter()
.map(|str| str.to_string())
.map(to_string)
.collect::<Vec<String>>(),
);

Expand All @@ -58,7 +59,7 @@ mod tests {
let result = NonInteractiveClapReal.non_interactive_initial_clap_operations(
&vec!["masq", "--ui-port", "10000", "setup", "--log-level", "off"]
.iter()
.map(|str| str.to_string())
.map(to_string)
.collect::<Vec<String>>(),
);

Expand Down
Loading

0 comments on commit 4ced510

Please sign in to comment.