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 Feb 6, 2024
2 parents 06aea8e + bd56d3f commit 595a806
Show file tree
Hide file tree
Showing 89 changed files with 4,821 additions and 1,692 deletions.
4 changes: 2 additions & 2 deletions automap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion automap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "automap"
version = "0.7.3"
version = "0.8.0"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
description = "Library full of code to make routers map ports through firewalls"
Expand Down
4 changes: 2 additions & 2 deletions dns_utility/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dns_utility/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dns_utility"
version = "0.7.3"
version = "0.8.0"
license = "GPL-3.0-only"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
copyright = "Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved."
Expand Down
2 changes: 1 addition & 1 deletion masq/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masq"
version = "0.7.3"
version = "0.8.0"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
description = "Reference implementation of user interface for MASQ Node"
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/change_password_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use clap::{App, Arg, SubCommand};
use masq_lib::messages::{
UiChangePasswordRequest, UiChangePasswordResponse, UiNewPasswordBroadcast,
};
use masq_lib::{as_any_in_trait_impl, short_writeln};
use masq_lib::{as_any_ref_in_trait_impl, short_writeln};
use std::io::Write;

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

as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

pub fn change_password_subcommand() -> App<'static, 'static> {
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/check_password_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::commands::commands_common::{
transaction, Command, CommandError, STANDARD_COMMAND_TIMEOUT_MILLIS,
};
use clap::{App, Arg, SubCommand};
use masq_lib::as_any_in_trait_impl;
use masq_lib::as_any_ref_in_trait_impl;
use masq_lib::messages::{UiCheckPasswordRequest, UiCheckPasswordResponse};
use masq_lib::short_writeln;
use masq_lib::utils::to_string;
Expand Down Expand Up @@ -51,7 +51,7 @@ impl Command for CheckPasswordCommand {
Ok(())
}

as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

impl CheckPasswordCommand {
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/configuration_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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::as_any_ref_in_trait_impl;
use masq_lib::constants::NODE_NOT_RUNNING_ERROR;
use masq_lib::messages::{UiConfigurationRequest, UiConfigurationResponse};
use masq_lib::short_writeln;
Expand Down Expand Up @@ -64,7 +64,7 @@ impl Command for ConfigurationCommand {
}
}

as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

impl ConfigurationCommand {
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/connection_status_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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::as_any_ref_in_trait_impl;
use masq_lib::constants::NODE_NOT_RUNNING_ERROR;
use masq_lib::messages::{
UiConnectionStage, UiConnectionStatusRequest, UiConnectionStatusResponse,
Expand Down Expand Up @@ -62,7 +62,7 @@ impl Command for ConnectionStatusCommand {
}
}

as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

impl ConnectionStatusCommand {
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/generate_wallets_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::commands::commands_common::{
};
use clap::{App, Arg, SubCommand};
use lazy_static::lazy_static;
use masq_lib::as_any_in_trait_impl;
use masq_lib::as_any_ref_in_trait_impl;
use masq_lib::messages::{UiGenerateSeedSpec, UiGenerateWalletsRequest, UiGenerateWalletsResponse};
use masq_lib::short_writeln;
use masq_lib::utils::DEFAULT_EARNING_DERIVATION_PATH;
Expand Down Expand Up @@ -165,7 +165,7 @@ impl Command for GenerateWalletsCommand {
Ok(())
}

as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

pub fn generate_wallets_subcommand() -> App<'static, 'static> {
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/recover_wallets_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::commands::commands_common::{
};
use clap::{App, Arg, ArgGroup, SubCommand};
use itertools::{Either, Itertools};
use masq_lib::as_any_in_trait_impl;
use masq_lib::as_any_ref_in_trait_impl;
use masq_lib::messages::{UiRecoverSeedSpec, UiRecoverWalletsRequest, UiRecoverWalletsResponse};
use masq_lib::short_writeln;
use masq_lib::utils::to_string;
Expand Down Expand Up @@ -120,7 +120,7 @@ impl Command for RecoverWalletsCommand {
Ok(())
}

as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

const RECOVER_WALLETS_ABOUT: &str =
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/set_configuration_command.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::command_context::CommandContext;
use crate::commands::commands_common::{transaction, Command, CommandError};
use clap::{App, Arg, ArgGroup, SubCommand};
use masq_lib::as_any_in_trait_impl;
use masq_lib::as_any_ref_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;
Expand Down Expand Up @@ -53,7 +53,7 @@ impl Command for SetConfigurationCommand {
Ok(())
}

as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

const SET_CONFIGURATION_ABOUT: &str =
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/setup_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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::as_any_ref_in_trait_impl;
use masq_lib::constants::SETUP_ERROR;
use masq_lib::messages::{
UiSetupBroadcast, UiSetupInner, UiSetupRequest, UiSetupRequestValue, UiSetupResponse,
Expand Down Expand Up @@ -51,7 +51,7 @@ impl Command for SetupCommand {
Err(e) => Err(e),
}
}
as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

impl SetupCommand {
Expand Down
4 changes: 2 additions & 2 deletions masq/src/commands/wallet_addresses_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::commands::commands_common::{
};
use clap::{App, Arg, SubCommand};
use masq_lib::messages::{UiWalletAddressesRequest, UiWalletAddressesResponse};
use masq_lib::{as_any_in_trait_impl, short_writeln};
use masq_lib::{as_any_ref_in_trait_impl, short_writeln};

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

#[cfg(test)]
Expand Down
6 changes: 3 additions & 3 deletions masq/src/communications/broadcast_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use masq_lib::messages::{
};
use masq_lib::ui_gateway::MessageBody;
use masq_lib::utils::ExpectValue;
use masq_lib::{as_any_in_trait, as_any_in_trait_impl, short_writeln};
use masq_lib::{as_any_ref_in_trait, as_any_ref_in_trait_impl, short_writeln};
use std::fmt::Debug;
use std::io::Write;
use std::thread;
Expand All @@ -20,15 +20,15 @@ use crate::notifications::connection_change_notification::ConnectionChangeNotifi

pub trait BroadcastHandle: Send {
fn send(&self, message_body: MessageBody);
as_any_in_trait!();
as_any_ref_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) {}
as_any_in_trait_impl!();
as_any_ref_in_trait_impl!();
}

pub struct BroadcastHandleGeneric {
Expand Down
2 changes: 1 addition & 1 deletion masq_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masq_lib"
version = "0.7.3"
version = "0.8.0"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
description = "Code common to Node and masq; also, temporarily, to dns_utility"
Expand Down
25 changes: 23 additions & 2 deletions masq_lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ macro_rules! intentionally_blank {
}

#[macro_export]
macro_rules! as_any_in_trait {
macro_rules! as_any_ref_in_trait {
() => {
#[cfg(test)]
fn as_any(&self) -> &dyn std::any::Any {
Expand All @@ -423,7 +423,7 @@ macro_rules! as_any_in_trait {
}

#[macro_export]
macro_rules! as_any_in_trait_impl {
macro_rules! as_any_ref_in_trait_impl {
() => {
#[cfg(test)]
fn as_any(&self) -> &dyn std::any::Any {
Expand All @@ -432,6 +432,27 @@ macro_rules! as_any_in_trait_impl {
};
}

#[macro_export]
macro_rules! as_any_mut_in_trait {
() => {
#[cfg(test)]
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
use masq_lib::intentionally_blank;
intentionally_blank!()
}
};
}

#[macro_export]
macro_rules! as_any_mut_in_trait_impl {
() => {
#[cfg(test)]
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
};
}

#[macro_export]
macro_rules! test_only_use {
($($use_clause: item),+) => {
Expand Down
2 changes: 1 addition & 1 deletion multinode_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "multinode_integration_tests"
version = "0.7.3"
version = "0.8.0"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
description = ""
Expand Down
30 changes: 29 additions & 1 deletion multinode_integration_tests/src/masq_mock_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use node_lib::sub_lib::cryptde::{encodex, CryptDE};
use node_lib::sub_lib::cryptde_null::CryptDENull;
use node_lib::sub_lib::cryptde_real::CryptDEReal;
use node_lib::sub_lib::framer::Framer;
use node_lib::sub_lib::hopper::{IncipientCoresPackage, MessageType};
use node_lib::sub_lib::hopper::{
ExpiredCoresPackage, IncipientCoresPackage, MessageType, MessageTypeLite,
};
use node_lib::sub_lib::neighborhood::{GossipFailure_0v1, RatePack, DEFAULT_RATE_PACK};
use node_lib::sub_lib::node_addr::NodeAddr;
use node_lib::sub_lib::route::Route;
Expand Down Expand Up @@ -394,6 +396,32 @@ impl MASQMockNode {
Ok((socket_from, socket_to, live_cores_package))
}

pub fn wait_for_specific_package(
&self,
message_type_lite: MessageTypeLite,
immediate_neighbor: SocketAddr,
) -> Option<ExpiredCoresPackage<MessageType>> {
let public_key = self.main_public_key();
let cryptde = CryptDENull::from(public_key, TEST_DEFAULT_MULTINODE_CHAIN);
loop {
if let Ok((_, _, live_cores_package)) =
self.wait_for_package(&JsonMasquerader::new(), Duration::from_secs(2))
{
let (_, intended_exit_public_key) =
CryptDENull::extract_key_pair(public_key.len(), &live_cores_package.payload);
assert_eq!(&intended_exit_public_key, public_key);
let expired_cores_package = live_cores_package
.to_expired(immediate_neighbor, &cryptde, &cryptde)
.unwrap();
if message_type_lite == expired_cores_package.payload.clone().into() {
return Some(expired_cores_package);
}
} else {
return None;
}
}
}

pub fn wait_for_gossip(&self, timeout: Duration) -> Option<(Gossip_0v1, IpAddr)> {
let masquerader = JsonMasquerader::new();
match self.wait_for_package(&masquerader, timeout) {
Expand Down
Loading

0 comments on commit 595a806

Please sign in to comment.