From 60d46dad03a80ceaa7564888e567d0a4def4b755 Mon Sep 17 00:00:00 2001 From: Bert <65427484+bertllll@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:08:37 +0200 Subject: [PATCH] GH-781: New Testnet Polygon Amoy (#431) * GH-781: experimenting with a test utility * GH-781: task might be complete now * GH-781: debugging for windows * GH-781: trying to satisfy Win * GH-781: clippy * GH-781: removed bad solution for issue that now a new card was written for * GH-781: cargo.toml change * GH-781: review answered --------- Co-authored-by: Bert --- masq/src/commands/configuration_command.rs | 4 +- masq/src/commands/setup_command.rs | 14 +-- .../src/blockchains/blockchain_records.rs | 75 ++++++------ masq_lib/src/blockchains/chains.rs | 8 +- masq_lib/src/constants.rs | 20 ++-- masq_lib/src/shared_schema.rs | 10 +- masq_lib/src/test_utils/utils.rs | 12 +- masq_lib/src/utils.rs | 8 +- node/docs/Blockchain-Service.md | 16 +-- node/src/apps.rs | 8 +- node/src/blockchain/blockchain_bridge.rs | 2 +- .../blockchain_interface_web3/mod.rs | 111 ++++++++++-------- node/src/blockchain/test_utils.rs | 2 +- node/src/bootstrapper.rs | 2 +- node/src/daemon/mod.rs | 2 +- node/src/daemon/setup_reporter.rs | 86 +++++++------- node/src/database/config_dumper.rs | 8 +- node/src/node_configurator/mod.rs | 37 ++++-- .../node_configurator_standard.rs | 75 ++++++------ node/src/privilege_drop.rs | 8 +- node/src/run_modes_factories.rs | 4 +- node/src/server_initializer.rs | 2 +- node/src/sub_lib/neighborhood.rs | 10 +- node/src/test_utils/mod.rs | 2 +- node/tests/contract_test.rs | 11 +- node/tests/dump_configuration_test.rs | 4 +- .../node_exits_from_future_panic_test.rs | 2 +- 27 files changed, 290 insertions(+), 253 deletions(-) diff --git a/masq/src/commands/configuration_command.rs b/masq/src/commands/configuration_command.rs index 8701f1617..f9e72d5d4 100644 --- a/masq/src/commands/configuration_command.rs +++ b/masq/src/commands/configuration_command.rs @@ -410,7 +410,7 @@ mod tests { blockchain_service_url_opt: Some("https://infura.io/ID".to_string()), current_schema_version: "schema version".to_string(), clandestine_port: 1234, - chain_name: "mumbai".to_string(), + chain_name: "amoy".to_string(), gas_price: 2345, max_block_count_opt: Some(100_000), neighborhood_mode: "zero-hop".to_string(), @@ -467,7 +467,7 @@ mod tests { "\ |NAME VALUE\n\ |Blockchain service URL: https://infura.io/ID\n\ -|Chain: mumbai\n\ +|Chain: amoy\n\ |Clandestine port: 1234\n\ |Consuming wallet private key: [?]\n\ |Current schema version: schema version\n\ diff --git a/masq/src/commands/setup_command.rs b/masq/src/commands/setup_command.rs index 92f605247..eaeede3c8 100644 --- a/masq/src/commands/setup_command.rs +++ b/masq/src/commands/setup_command.rs @@ -391,10 +391,10 @@ ip No sir, I don't like it.\n\ status_data_dir: UiSetupResponseValueStatus::Default, }, SetupCommandData { - chain_str: Some("polygon-mumbai".to_owned()), + chain_str: Some("polygon-amoy".to_owned()), data_directory: None, - chain_name_expected: Some("polygon-mumbai"), - data_directory_expected: Some("/home/cooga/.local/MASQ/polygon-mumbai"), + chain_name_expected: Some("polygon-amoy"), + data_directory_expected: Some("/home/cooga/.local/MASQ/polygon-amoy"), note_expected: true, status_chain: UiSetupResponseValueStatus::Set, status_data_dir: UiSetupResponseValueStatus::Default, @@ -409,10 +409,10 @@ ip No sir, I don't like it.\n\ status_data_dir: UiSetupResponseValueStatus::Set, }, SetupCommandData { - chain_str: Some("polygon-mumbai".to_owned()), - data_directory: Some("booga/polygon-mumbai".to_owned()), - chain_name_expected: Some("polygon-mumbai"), - data_directory_expected: Some("booga/polygon-mumbai/polygon-mumbai"), + chain_str: Some("polygon-amoy".to_owned()), + data_directory: Some("booga/polygon-amoy".to_owned()), + chain_name_expected: Some("polygon-amoy"), + data_directory_expected: Some("booga/polygon-amoy/polygon-amoy"), note_expected: true, status_chain: UiSetupResponseValueStatus::Set, status_data_dir: UiSetupResponseValueStatus::Set, diff --git a/masq_lib/src/blockchains/blockchain_records.rs b/masq_lib/src/blockchains/blockchain_records.rs index f9b4bcab0..5227195f7 100644 --- a/masq_lib/src/blockchains/blockchain_records.rs +++ b/masq_lib/src/blockchains/blockchain_records.rs @@ -2,15 +2,14 @@ use crate::blockchains::chains::Chain; use crate::constants::{ - DEV_CHAIN_FULL_IDENTIFIER, ETH_MAINNET_CONTRACT_CREATION_BLOCK, ETH_MAINNET_FULL_IDENTIFIER, - ETH_ROPSTEN_FULL_IDENTIFIER, MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK, - MUMBAI_TESTNET_CONTRACT_CREATION_BLOCK, POLYGON_MAINNET_CONTRACT_CREATION_BLOCK, - POLYGON_MAINNET_FULL_IDENTIFIER, POLYGON_MUMBAI_FULL_IDENTIFIER, + AMOY_TESTNET_CONTRACT_CREATION_BLOCK, DEV_CHAIN_FULL_IDENTIFIER, + ETH_MAINNET_CONTRACT_CREATION_BLOCK, ETH_MAINNET_FULL_IDENTIFIER, ETH_ROPSTEN_FULL_IDENTIFIER, + MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK, POLYGON_AMOY_FULL_IDENTIFIER, + POLYGON_MAINNET_CONTRACT_CREATION_BLOCK, POLYGON_MAINNET_FULL_IDENTIFIER, ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK, }; use ethereum_types::{Address, H160}; -//chains are ordered by their significance for the community of users (the order reflects in some error or help messages) pub const CHAINS: [BlockchainRecord; 5] = [ BlockchainRecord { self_id: Chain::PolyMainnet, @@ -27,11 +26,11 @@ pub const CHAINS: [BlockchainRecord; 5] = [ contract_creation_block: ETH_MAINNET_CONTRACT_CREATION_BLOCK, }, BlockchainRecord { - self_id: Chain::PolyMumbai, - num_chain_id: 80001, - literal_identifier: POLYGON_MUMBAI_FULL_IDENTIFIER, - contract: MUMBAI_TESTNET_CONTRACT_ADDRESS, - contract_creation_block: MUMBAI_TESTNET_CONTRACT_CREATION_BLOCK, + self_id: Chain::PolyAmoy, + num_chain_id: 80002, + literal_identifier: POLYGON_AMOY_FULL_IDENTIFIER, + contract: AMOY_TESTNET_CONTRACT_ADDRESS, + contract_creation_block: AMOY_TESTNET_CONTRACT_CREATION_BLOCK, }, BlockchainRecord { self_id: Chain::EthRopsten, @@ -58,6 +57,22 @@ pub struct BlockchainRecord { pub contract_creation_block: u64, } +const POLYGON_MAINNET_CONTRACT_ADDRESS: Address = H160([ + 0xee, 0x9a, 0x35, 0x2f, 0x6a, 0xac, 0x4a, 0xf1, 0xa5, 0xb9, 0xf4, 0x67, 0xf6, 0xa9, 0x3e, 0x0f, + 0xfb, 0xe9, 0xdd, 0x35, +]); + +const ETH_MAINNET_CONTRACT_ADDRESS: Address = H160([ + 0x06, 0xf3, 0xc3, 0x23, 0xf0, 0x23, 0x8c, 0x72, 0xbf, 0x35, 0x01, 0x10, 0x71, 0xf2, 0xb5, 0xb7, + 0xf4, 0x3a, 0x05, 0x4c, +]); + +// $tMASQ (Amoy) +const AMOY_TESTNET_CONTRACT_ADDRESS: Address = H160([ + 0xd9, 0x8c, 0x3e, 0xbd, 0x6b, 0x7f, 0x9b, 0x7c, 0xda, 0x24, 0x49, 0xec, 0xac, 0x00, 0xd1, 0xe5, + 0xf4, 0x7a, 0x81, 0x93, +]); + // SHRD (Ropsten) const ROPSTEN_TESTNET_CONTRACT_ADDRESS: Address = H160([ 0x38, 0x4d, 0xec, 0x25, 0xe0, 0x3f, 0x94, 0x93, 0x17, 0x67, 0xce, 0x4c, 0x35, 0x56, 0x16, 0x84, @@ -69,30 +84,12 @@ const MULTINODE_TESTNET_CONTRACT_ADDRESS: Address = H160([ 0xf1, 0xb3, 0xe6, 0x64, ]); -const ETH_MAINNET_CONTRACT_ADDRESS: Address = H160([ - 0x06, 0xF3, 0xC3, 0x23, 0xf0, 0x23, 0x8c, 0x72, 0xBF, 0x35, 0x01, 0x10, 0x71, 0xf2, 0xb5, 0xB7, - 0xF4, 0x3A, 0x05, 0x4c, -]); - -#[allow(clippy::mixed_case_hex_literals)] -const POLYGON_MAINNET_CONTRACT_ADDRESS: Address = H160([ - 0xEe, 0x9A, 0x35, 0x2F, 0x6a, 0xAc, 0x4a, 0xF1, 0xA5, 0xB9, 0xf4, 0x67, 0xF6, 0xa9, 0x3E, 0x0f, - 0xfB, 0xe9, 0xDd, 0x35, -]); - -// $tMASQ (Mumbai) -#[allow(clippy::mixed_case_hex_literals)] -const MUMBAI_TESTNET_CONTRACT_ADDRESS: Address = H160([ - 0x9B, 0x27, 0x03, 0x4a, 0xca, 0xBd, 0x44, 0x22, 0x3f, 0xB2, 0x3d, 0x62, 0x8B, 0xa4, 0x84, 0x98, - 0x67, 0xcE, 0x1D, 0xB2, -]); - #[cfg(test)] mod tests { use super::*; use crate::blockchains::chains::chain_from_chain_identifier_opt; use crate::constants::{ - MUMBAI_TESTNET_CONTRACT_CREATION_BLOCK, POLYGON_MAINNET_CONTRACT_CREATION_BLOCK, + AMOY_TESTNET_CONTRACT_CREATION_BLOCK, POLYGON_MAINNET_CONTRACT_CREATION_BLOCK, }; use std::collections::HashSet; use std::iter::FromIterator; @@ -104,7 +101,7 @@ mod tests { assert_returns_correct_record(Chain::Dev, 2), assert_returns_correct_record(Chain::EthRopsten, 3), assert_returns_correct_record(Chain::PolyMainnet, 137), - assert_returns_correct_record(Chain::PolyMumbai, 80001), + assert_returns_correct_record(Chain::PolyAmoy, 80002), ]; assert_exhaustive(&test_array) } @@ -118,7 +115,7 @@ mod tests { fn from_str_works() { let test_array = [ assert_from_str(Chain::PolyMainnet), - assert_from_str(Chain::PolyMumbai), + assert_from_str(Chain::PolyAmoy), assert_from_str(Chain::EthMainnet), assert_from_str(Chain::EthRopsten), assert_from_str(Chain::Dev), @@ -142,7 +139,7 @@ mod tests { let test_array = [ assert_chain_significance(0, Chain::PolyMainnet), assert_chain_significance(1, Chain::EthMainnet), - assert_chain_significance(2, Chain::PolyMumbai), + assert_chain_significance(2, Chain::PolyAmoy), assert_chain_significance(3, Chain::EthRopsten), assert_chain_significance(4, Chain::Dev), ]; @@ -203,17 +200,17 @@ mod tests { } #[test] - fn mumbai_record_is_properly_declared() { - let examined_chain = Chain::PolyMumbai; + fn amoy_record_is_properly_declared() { + let examined_chain = Chain::PolyAmoy; let chain_record = return_examined(examined_chain); assert_eq!( chain_record, &BlockchainRecord { - num_chain_id: 80001, + num_chain_id: 80002, self_id: examined_chain, - literal_identifier: "polygon-mumbai", - contract: MUMBAI_TESTNET_CONTRACT_ADDRESS, - contract_creation_block: MUMBAI_TESTNET_CONTRACT_CREATION_BLOCK, + literal_identifier: "polygon-amoy", + contract: AMOY_TESTNET_CONTRACT_ADDRESS, + contract_creation_block: AMOY_TESTNET_CONTRACT_CREATION_BLOCK, } ); } @@ -245,7 +242,7 @@ mod tests { assert_chain_from_chain_identifier_opt("eth-ropsten", Some(Chain::EthRopsten)), assert_chain_from_chain_identifier_opt("dev", Some(Chain::Dev)), assert_chain_from_chain_identifier_opt("polygon-mainnet", Some(Chain::PolyMainnet)), - assert_chain_from_chain_identifier_opt("polygon-mumbai", Some(Chain::PolyMumbai)), + assert_chain_from_chain_identifier_opt("polygon-amoy", Some(Chain::PolyAmoy)), ]; assert_exhaustive(&test_array) } diff --git a/masq_lib/src/blockchains/chains.rs b/masq_lib/src/blockchains/chains.rs index ac3fbbac0..433d5524c 100644 --- a/masq_lib/src/blockchains/chains.rs +++ b/masq_lib/src/blockchains/chains.rs @@ -3,7 +3,7 @@ use crate::blockchains::blockchain_records::{BlockchainRecord, CHAINS}; use crate::constants::{ DEFAULT_CHAIN, DEV_CHAIN_FULL_IDENTIFIER, ETH_MAINNET_FULL_IDENTIFIER, - ETH_ROPSTEN_FULL_IDENTIFIER, POLYGON_MAINNET_FULL_IDENTIFIER, POLYGON_MUMBAI_FULL_IDENTIFIER, + ETH_ROPSTEN_FULL_IDENTIFIER, POLYGON_AMOY_FULL_IDENTIFIER, POLYGON_MAINNET_FULL_IDENTIFIER, }; use serde_derive::{Deserialize, Serialize}; @@ -12,7 +12,7 @@ pub enum Chain { EthMainnet, EthRopsten, PolyMainnet, - PolyMumbai, + PolyAmoy, Dev, } @@ -28,8 +28,8 @@ impl From<&str> for Chain { Chain::PolyMainnet } else if str == ETH_MAINNET_FULL_IDENTIFIER { Chain::EthMainnet - } else if str == POLYGON_MUMBAI_FULL_IDENTIFIER { - Chain::PolyMumbai + } else if str == POLYGON_AMOY_FULL_IDENTIFIER { + Chain::PolyAmoy } else if str == ETH_ROPSTEN_FULL_IDENTIFIER { Chain::EthRopsten } else if str == DEV_CHAIN_FULL_IDENTIFIER { diff --git a/masq_lib/src/constants.rs b/masq_lib/src/constants.rs index 7bdcbe1e1..1a0542837 100644 --- a/masq_lib/src/constants.rs +++ b/masq_lib/src/constants.rs @@ -26,9 +26,9 @@ pub const WEIS_IN_GWEI: i128 = 1_000_000_000; pub const ETH_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 11_170_708; pub const ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 8_688_171; -pub const MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 0; pub const POLYGON_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 14_863_650; -pub const MUMBAI_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 24_638_838; +pub const AMOY_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 5_323_366; +pub const MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 0; //Migration versions //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -87,15 +87,15 @@ pub const CENTRAL_DELIMITER: char = '@'; pub const CHAIN_IDENTIFIER_DELIMITER: char = ':'; //chains -const MAINNET: &str = "mainnet"; const POLYGON_FAMILY: &str = "polygon"; const ETH_FAMILY: &str = "eth"; +const MAINNET: &str = "mainnet"; const LINK: char = '-'; pub const POLYGON_MAINNET_FULL_IDENTIFIER: &str = concatcp!(POLYGON_FAMILY, LINK, MAINNET); -pub const POLYGON_MUMBAI_FULL_IDENTIFIER: &str = concatcp!(POLYGON_FAMILY, LINK, "mumbai"); -pub const DEV_CHAIN_FULL_IDENTIFIER: &str = "dev"; +pub const POLYGON_AMOY_FULL_IDENTIFIER: &str = concatcp!(POLYGON_FAMILY, LINK, "amoy"); pub const ETH_MAINNET_FULL_IDENTIFIER: &str = concatcp!(ETH_FAMILY, LINK, MAINNET); pub const ETH_ROPSTEN_FULL_IDENTIFIER: &str = concatcp!(ETH_FAMILY, LINK, "ropsten"); +pub const DEV_CHAIN_FULL_IDENTIFIER: &str = "dev"; #[cfg(test)] mod tests { @@ -119,9 +119,9 @@ mod tests { assert_eq!(WEIS_IN_GWEI, 1_000_000_000); assert_eq!(ETH_MAINNET_CONTRACT_CREATION_BLOCK, 11_170_708); assert_eq!(ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK, 8_688_171); - assert_eq!(MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK, 0); assert_eq!(POLYGON_MAINNET_CONTRACT_CREATION_BLOCK, 14_863_650); - assert_eq!(MUMBAI_TESTNET_CONTRACT_CREATION_BLOCK, 24_638_838); + assert_eq!(AMOY_TESTNET_CONTRACT_CREATION_BLOCK, 5_323_366); + assert_eq!(MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK, 0); assert_eq!(CONFIGURATOR_PREFIX, 0x0001_0000_0000_0000); assert_eq!(CONFIGURATOR_READ_ERROR, CONFIGURATOR_PREFIX | 1); assert_eq!(CONFIGURATOR_WRITE_ERROR, CONFIGURATOR_PREFIX | 2); @@ -157,15 +157,15 @@ mod tests { assert_eq!(VALUE_EXCEEDS_ALLOWED_LIMIT, ACCOUNTANT_PREFIX | 3); assert_eq!(CENTRAL_DELIMITER, '@'); assert_eq!(CHAIN_IDENTIFIER_DELIMITER, ':'); - assert_eq!(MAINNET, "mainnet"); assert_eq!(POLYGON_FAMILY, "polygon"); assert_eq!(ETH_FAMILY, "eth"); + assert_eq!(MAINNET, "mainnet"); assert_eq!(LINK, '-'); assert_eq!(POLYGON_MAINNET_FULL_IDENTIFIER, "polygon-mainnet"); - assert_eq!(POLYGON_MUMBAI_FULL_IDENTIFIER, "polygon-mumbai"); - assert_eq!(DEV_CHAIN_FULL_IDENTIFIER, "dev"); + assert_eq!(POLYGON_AMOY_FULL_IDENTIFIER, "polygon-amoy"); assert_eq!(ETH_MAINNET_FULL_IDENTIFIER, "eth-mainnet"); assert_eq!(ETH_ROPSTEN_FULL_IDENTIFIER, "eth-ropsten"); + assert_eq!(DEV_CHAIN_FULL_IDENTIFIER, "dev"); assert_eq!( CLIENT_REQUEST_PAYLOAD_CURRENT_VERSION, DataVersion { major: 0, minor: 1 } diff --git a/masq_lib/src/shared_schema.rs b/masq_lib/src/shared_schema.rs index fc7e8ced2..cc3e34b54 100644 --- a/masq_lib/src/shared_schema.rs +++ b/masq_lib/src/shared_schema.rs @@ -3,7 +3,7 @@ use crate::constants::{ DEFAULT_GAS_PRICE, DEFAULT_UI_PORT, DEV_CHAIN_FULL_IDENTIFIER, ETH_MAINNET_FULL_IDENTIFIER, ETH_ROPSTEN_FULL_IDENTIFIER, HIGHEST_USABLE_PORT, LOWEST_USABLE_INSECURE_PORT, - POLYGON_MAINNET_FULL_IDENTIFIER, POLYGON_MUMBAI_FULL_IDENTIFIER, + POLYGON_AMOY_FULL_IDENTIFIER, POLYGON_MAINNET_FULL_IDENTIFIER, }; use crate::crash_point::CrashPoint; use clap::{App, Arg}; @@ -64,7 +64,7 @@ pub const NEIGHBORS_HELP: &str = "One or more Node descriptors for running Nodes on startup. A Node descriptor looks similar to one of these:\n\n\ masq://polygon-mainnet:d2U3Dv1BqtS5t_Zz3mt9_sCl7AgxUlnkB4jOMElylrU@172.50.48.6:9342\n\ masq://eth-mainnet:gBviQbjOS3e5ReFQCvIhUM3i02d1zPleo1iXg_EN6zQ@86.75.30.9:5542\n\ - masq://polygon-mumbai:A6PGHT3rRjaeFpD_rFi3qGEXAVPq7bJDfEUZpZaIyq8@14.10.50.6:10504\n\ + masq://polygon-amoy:A6PGHT3rRjaeFpD_rFi3qGEXAVPq7bJDfEUZpZaIyq8@14.10.50.6:10504\n\ masq://eth-ropsten:OHsC2CAm4rmfCkaFfiynwxflUgVTJRb2oY5mWxNCQkY@150.60.42.72:6642/4789/5254\n\n\ Notice each of the different chain identifiers in the masq protocol prefix - they determine a family of chains \ and also the network the descriptor belongs to (mainnet or a testnet). See also the last descriptor which shows \ @@ -256,7 +256,7 @@ pub fn official_chain_names() -> &'static [&'static str] { &[ POLYGON_MAINNET_FULL_IDENTIFIER, ETH_MAINNET_FULL_IDENTIFIER, - POLYGON_MUMBAI_FULL_IDENTIFIER, + POLYGON_AMOY_FULL_IDENTIFIER, ETH_ROPSTEN_FULL_IDENTIFIER, DEV_CHAIN_FULL_IDENTIFIER, ] @@ -757,7 +757,7 @@ mod tests { on startup. A Node descriptor looks similar to one of these:\n\n\ masq://polygon-mainnet:d2U3Dv1BqtS5t_Zz3mt9_sCl7AgxUlnkB4jOMElylrU@172.50.48.6:9342\n\ masq://eth-mainnet:gBviQbjOS3e5ReFQCvIhUM3i02d1zPleo1iXg_EN6zQ@86.75.30.9:5542\n\ - masq://polygon-mumbai:A6PGHT3rRjaeFpD_rFi3qGEXAVPq7bJDfEUZpZaIyq8@14.10.50.6:10504\n\ + masq://polygon-amoy:A6PGHT3rRjaeFpD_rFi3qGEXAVPq7bJDfEUZpZaIyq8@14.10.50.6:10504\n\ masq://eth-ropsten:OHsC2CAm4rmfCkaFfiynwxflUgVTJRb2oY5mWxNCQkY@150.60.42.72:6642/4789/5254\n\n\ Notice each of the different chain identifiers in the masq protocol prefix - they determine a family of chains \ and also the network the descriptor belongs to (mainnet or a testnet). See also the last descriptor which shows \ @@ -1144,7 +1144,7 @@ mod tests { let mut iterator = official_chain_names().iter(); assert_eq!(Chain::from(*iterator.next().unwrap()), Chain::PolyMainnet); assert_eq!(Chain::from(*iterator.next().unwrap()), Chain::EthMainnet); - assert_eq!(Chain::from(*iterator.next().unwrap()), Chain::PolyMumbai); + assert_eq!(Chain::from(*iterator.next().unwrap()), Chain::PolyAmoy); assert_eq!(Chain::from(*iterator.next().unwrap()), Chain::EthRopsten); assert_eq!(Chain::from(*iterator.next().unwrap()), Chain::Dev); assert_eq!(iterator.next(), None) diff --git a/masq_lib/src/test_utils/utils.rs b/masq_lib/src/test_utils/utils.rs index ddc32e7bc..2fed96981 100644 --- a/masq_lib/src/test_utils/utils.rs +++ b/masq_lib/src/test_utils/utils.rs @@ -30,8 +30,16 @@ pub fn ensure_node_home_directory_exists(module: &str, name: &str) -> PathBuf { } pub fn is_running_under_github_actions() -> bool { - if let Ok(value) = std::env::var("GITHUB_ACTIONS") { - &value == "true" + is_env_variable_set("GITHUB_ACTIONS", "true") +} + +pub fn is_test_generated_data_allowed_to_escape_project_dir() -> bool { + is_env_variable_set("ALLOW_TEST_DATA_ESCAPE_PROJECT_DIR", "true") +} + +fn is_env_variable_set(var_name: &str, searched_value: &str) -> bool { + if let Ok(value) = std::env::var(var_name) { + value == searched_value } else { false } diff --git a/masq_lib/src/utils.rs b/masq_lib/src/utils.rs index 1083af2b9..8d563ef37 100644 --- a/masq_lib/src/utils.rs +++ b/masq_lib/src/utils.rs @@ -49,14 +49,14 @@ fn compute_data_directory_help() -> String { let polygon_mainnet_dir = Path::new(&data_dir.to_str().unwrap()) .join("MASQ") .join("polygon-mainnet"); - let polygon_mumbai_dir = Path::new(&data_dir.to_str().unwrap()) + let polygon_amoy_dir = Path::new(&data_dir.to_str().unwrap()) .join("MASQ") - .join("polygon-mumbai"); + .join("polygon-amoy"); format!("Directory in which the Node will store its persistent state, including at least its database \ and by default its configuration file as well. By default, your data-directory is located in \ your application directory, under your home directory e.g.: '{}'.\n\n\ In case you change your chain to a different one, the data-directory path is automatically changed \ - to end with the name of your chain: e.g.: if you choose polygon-mumbai, then data-directory is \ + to end with the name of your chain: e.g.: if you choose polygon-amoy, then data-directory is \ automatically changed to: '{}'.\n\n\ You can specify your own data-directory to the Daemon in two different ways: \n\n\ 1. If you provide a path without the chain name on the end, the Daemon will automatically change \ @@ -65,7 +65,7 @@ fn compute_data_directory_help() -> String { 2. If you provide your data directory with the corresponding chain name on the end, eg: {}/masq_home/polygon-mainnet, \ there will be no change until you set the chain parameter to a different value.", polygon_mainnet_dir.to_string_lossy().to_string().as_str(), - polygon_mumbai_dir.to_string_lossy().to_string().as_str(), + polygon_amoy_dir.to_string_lossy().to_string().as_str(), &home_dir.to_string_lossy().to_string().as_str(), &home_dir.to_string_lossy().to_string().as_str(), home_dir.to_string_lossy().to_string().as_str() diff --git a/node/docs/Blockchain-Service.md b/node/docs/Blockchain-Service.md index 4f6e407cb..eb930736f 100644 --- a/node/docs/Blockchain-Service.md +++ b/node/docs/Blockchain-Service.md @@ -2,7 +2,7 @@ ### What is a blockchain service URL? -A blockchain service url is a URL that MASQ Node uses to interact with various blockchains, either the Mumbai and Ropsten +A blockchain service url is a URL that MASQ Node uses to interact with various blockchains, either the Amoy and Ropsten testnets or Polygon and Ethereum mainnets. On mainnets, MASQ uses the MASQ token; on testnets, it uses a test token. #### MASQ Node software supports connections to the following blockchains: @@ -11,7 +11,7 @@ testnets or Polygon and Ethereum mainnets. On mainnets, MASQ uses the MASQ token - [x] Ethereum mainnet **Polygon** -- [x] Mumbai testnet +- [x] Amoy testnet - [x] Polygon mainnet *in beta testing* To be fully functional MASQ Node needs communication to the blockchain for access to: @@ -29,27 +29,27 @@ There are two general types of Blockchain Services MASQ Node currently supports. ### 1. Sign up for a free [Infura.io](https://infura.io/register) account. Follow the instructions here [Infura.io/docs](https://infura.io/docs) to create a "Project" -Choose one of the following options for the network of your choice (if you are testing it is likely the Mumbai testnet): +Choose one of the following options for the network of your choice (if you are testing it is likely the Amoy testnet): -* Enter your Infura.io url `https://polygon-mumbai.infura.io/v3/` in the blockchain service url field of the GUI. +* Enter your Infura.io url `https://polygon-amoy.infura.io/v3/` in the blockchain service url field of the GUI. * For the `masq` command-line interface, use the `setup` command: - > `masq> setup --blockchain-service-url https://polygon-mumbai.infura.io/v3/` + > `masq> setup --blockchain-service-url https://polygon-amoy.infura.io/v3/` * Edit your config.toml file and include the entry - > `blockservice-service-url = "https://polygon-mumbai.infura.io/v3/"` + > `blockservice-service-url = "https://polygon-amoy.infura.io/v3/"` * Or define an environment variable * Windows - > `set MASQ_BLOCKCHAIN_SERVICE_URL = https://polygon-mumbai.infura.io/v3/` + > `set MASQ_BLOCKCHAIN_SERVICE_URL = https://polygon-amoy.infura.io/v3/` * Linux or macOS - > `export MASQ_BLOCKCHAIN_SERVICE_URL = https://polygon-mumbai.infura.io/v3/` + > `export MASQ_BLOCKCHAIN_SERVICE_URL = https://polygon-amoy.infura.io/v3/` Change `` with the PROJECT ID from your Infura.io Project Dashboard. Change the URL to mainnet when ready to spend and earn real MASQ. diff --git a/node/src/apps.rs b/node/src/apps.rs index 9aed6369b..66f2af1e6 100644 --- a/node/src/apps.rs +++ b/node/src/apps.rs @@ -107,9 +107,9 @@ mod tests { let polygon_mainnet_dir = Path::new(&data_dir.to_str().unwrap()) .join("MASQ") .join("polygon-mainnet"); - let polygon_mumbai_dir = Path::new(&data_dir.to_str().unwrap()) + let polygon_amoy_dir = Path::new(&data_dir.to_str().unwrap()) .join("MASQ") - .join("polygon-mumbai"); + .join("polygon-amoy"); assert_eq!( DATA_DIRECTORY_DAEMON_HELP.as_str(), @@ -117,7 +117,7 @@ mod tests { and by default its configuration file as well. By default, your data-directory is located in \ your application directory, under your home directory e.g.: '{}'.\n\n\ In case you change your chain to a different one, the data-directory path is automatically changed \ - to end with the name of your chain: e.g.: if you choose polygon-mumbai, then data-directory is \ + to end with the name of your chain: e.g.: if you choose polygon-amoy, then data-directory is \ automatically changed to: '{}'.\n\n\ You can specify your own data-directory to the Daemon in two different ways: \n\n\ 1. If you provide a path without the chain name on the end, the Daemon will automatically change \ @@ -126,7 +126,7 @@ mod tests { 2. If you provide your data directory with the corresponding chain name on the end, eg: {}/masq_home/polygon-mainnet, \ there will be no change until you set the chain parameter to a different value.", polygon_mainnet_dir.to_string_lossy().to_string().as_str(), - polygon_mumbai_dir.to_string_lossy().to_string().as_str(), + polygon_amoy_dir.to_string_lossy().to_string().as_str(), &home_dir.to_string_lossy().to_string().as_str(), &home_dir.to_string_lossy().to_string().as_str(), home_dir.to_string_lossy().to_string().as_str() diff --git a/node/src/blockchain/blockchain_bridge.rs b/node/src/blockchain/blockchain_bridge.rs index b0eab3bd4..d9f6c630e 100644 --- a/node/src/blockchain/blockchain_bridge.rs +++ b/node/src/blockchain/blockchain_bridge.rs @@ -1814,7 +1814,7 @@ mod tests { assert_eq!(Some(100000u64), max_block_count); } /* - POKT (Polygon mainnet and mumbai) + POKT (Polygon mainnet and amoy) {"jsonrpc":"2.0","id":7,"error":{"message":"You cannot query logs for more than 100000 blocks at once.","code":-32064}} */ /* diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs index 083f75822..09d54ad89 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs @@ -579,7 +579,7 @@ where fn web3_gas_limit_const_part(chain: Chain) -> u64 { match chain { Chain::EthMainnet | Chain::EthRopsten | Chain::Dev => 55_000, - Chain::PolyMainnet | Chain::PolyMumbai => 70_000, + Chain::PolyMainnet | Chain::PolyAmoy => 70_000, } } @@ -1107,7 +1107,7 @@ mod tests { #[test] fn build_of_the_blockchain_agent_fails_on_fetching_gas_price() { - let chain = Chain::PolyMumbai; + let chain = Chain::PolyAmoy; let wallet = make_wallet("abc"); let persistent_config = PersistentConfigurationMock::new().gas_price_result(Err( PersistentConfigError::UninterpretableValue("booga".to_string()), @@ -1281,9 +1281,14 @@ mod tests { Call::MethodCall(MethodCall { jsonrpc: Some(V2), method: "eth_sendRawTransaction".to_string(), - params: Params::Array(vec![Value::String("0xf8a906851bf08eb00082db6894384dec25e03f94931767ce4c3556168468ba24c380b844a9059cbb000\ - 00000000000000000000000000000000000000000000000000000773132330000000000000000000000000000000000000000000000000c7d713b49da00002aa060b9f375c06f56\ - 41951606643d76ef999d32ae02f6b6cd62c9275ebdaa36a390a0199c3d8644c428efd5e0e0698c031172ac6873037d90dcca36a1fbf2e67960ff".to_string())]), + params: Params::Array(vec![Value::String( + "0xf8a906851bf08eb00082db6894384de\ + c25e03f94931767ce4c3556168468ba24c380b844a9059cbb000000000000000000000000000000000000000000\ + 00000000000000773132330000000000000000000000000000000000000000000000000c7d713b49da00002aa06\ + 0b9f375c06f5641951606643d76ef999d32ae02f6b6cd62c9275ebdaa36a390a0199c3d8644c428efd5e0e0698c\ + 031172ac6873037d90dcca36a1fbf2e67960ff" + .to_string() + )]), id: Id::Num(1) }) ), @@ -1292,9 +1297,14 @@ mod tests { Call::MethodCall(MethodCall { jsonrpc: Some(V2), method: "eth_sendRawTransaction".to_string(), - params: Params::Array(vec![Value::String("0xf8a907851bf08eb00082dae894384dec25e03f94931767ce4c3556168468ba24c380b844a9059cbb000\ - 000000000000000000000000000000000000000000000000000007735353500000000000000000000000000000000000000000000000000000000075bcd1529a00e61352bb2ac9b\ - 32b411206250f219b35cdc85db679f3e2416daac4f730a12f1a02c2ad62759d86942f3af2b8915ecfbaa58268010e00d32c18a49a9fc3b9bd20a".to_string())]), + params: Params::Array(vec![Value::String( + "0xf8a907851bf08eb00082dae894384de\ + c25e03f94931767ce4c3556168468ba24c380b844a9059cbb000000000000000000000000000000000000000000\ + 000000000000007735353500000000000000000000000000000000000000000000000000000000075bcd1529a00\ + e61352bb2ac9b32b411206250f219b35cdc85db679f3e2416daac4f730a12f1a02c2ad62759d86942f3af2b8915\ + ecfbaa58268010e00d32c18a49a9fc3b9bd20a" + .to_string() + )]), id: Id::Num(1) }) ), @@ -1303,9 +1313,14 @@ mod tests { Call::MethodCall(MethodCall { jsonrpc: Some(V2), method: "eth_sendRawTransaction".to_string(), - params: Params::Array(vec![Value::String("0xf8a908851bf08eb00082db6894384dec25e03f94931767ce4c3556168468ba24c380b844a9059cbb000\ - 0000000000000000000000000000000000000000000000000000077393837000000000000000000000000000000000000000000000000007680cd2f2d34002aa02d300cc8ba7b63\ - b0147727c824a54a7db9ec083273be52a32bdca72657a3e310a042a17224b35e7036d84976a23fbe8b1a488b2bcabed1e4a2b0b03f0c9bbc38e9".to_string())]), + params: Params::Array(vec![Value::String( + "0xf8a908851bf08eb00082db6894384de\ + c25e03f94931767ce4c3556168468ba24c380b844a9059cbb000000000000000000000000000000000000000000\ + 0000000000000077393837000000000000000000000000000000000000000000000000007680cd2f2d34002aa02\ + d300cc8ba7b63b0147727c824a54a7db9ec083273be52a32bdca72657a3e310a042a17224b35e7036d84976a23f\ + be8b1a488b2bcabed1e4a2b0b03f0c9bbc38e9" + .to_string() + )]), id: Id::Num(1) }) ) @@ -1613,10 +1628,7 @@ mod tests { Subject::web3_gas_limit_const_part(Chain::PolyMainnet), 70_000 ); - assert_eq!( - Subject::web3_gas_limit_const_part(Chain::PolyMumbai), - 70_000 - ); + assert_eq!(Subject::web3_gas_limit_const_part(Chain::PolyAmoy), 70_000); assert_eq!(Subject::web3_gas_limit_const_part(Chain::Dev), 55_000); } @@ -1683,7 +1695,7 @@ mod tests { #[test] fn signing_error_terminates_iteration_over_accounts_and_propagates_it_all_way_up_and_out() { let transport = TestTransport::default(); - let chain = Chain::PolyMumbai; + let chain = Chain::PolyAmoy; let batch_payable_tools = BatchPayableToolsMock::::default() .sign_transaction_result(Err(Web3Error::Signing( secp256k1secrets::Error::InvalidSecretKey, @@ -1749,7 +1761,7 @@ mod tests { .batch_wide_timestamp_result(SystemTime::now()) .submit_batch_result(Err(Web3Error::Transport("Transaction crashed".to_string()))); let consuming_wallet_secret_raw_bytes = b"okay-wallet"; - let chain = Chain::PolyMumbai; + let chain = Chain::PolyAmoy; let mut subject = BlockchainInterfaceWeb3::new(transport, make_fake_event_loop_handle(), chain); subject.batch_payable_tools = Box::new(batch_payable_tools); @@ -1781,7 +1793,7 @@ mod tests { secp256k1secrets::Error::InvalidSecretKey, ))); let consuming_wallet_secret_raw_bytes = b"okay-wallet"; - let chain = Chain::PolyMumbai; + let chain = Chain::PolyAmoy; let mut subject = BlockchainInterfaceWeb3::new(transport, make_fake_event_loop_handle(), chain); subject.batch_payable_tools = Box::new(batch_payable_tools); @@ -1801,10 +1813,6 @@ mod tests { ); } - const TEST_PAYMENT_AMOUNT: u128 = 1_000_000_000_000; - const TEST_GAS_PRICE_ETH: u64 = 110; - const TEST_GAS_PRICE_POLYGON: u64 = 50; - fn test_consuming_wallet_with_secret() -> Wallet { let key_pair = Bip32EncryptionKeyProvider::from_raw_secret( &decode_hex("97923d8fd8de4a00f912bfb77ef483141dec551bd73ea59343ef5c4aac965d04") @@ -1832,12 +1840,13 @@ mod tests { let recipient_wallet = test_recipient_wallet(); let nonce_correct_type = U256::from(nonce); let gas_price = match chain { - Chain::EthMainnet | Chain::EthRopsten | Chain::Dev => TEST_GAS_PRICE_ETH, - Chain::PolyMainnet | Chain::PolyMumbai => TEST_GAS_PRICE_POLYGON, + Chain::EthMainnet | Chain::EthRopsten | Chain::Dev => 110, + Chain::PolyMainnet | Chain::PolyAmoy => 55, }; + let payment_size_wei = 1_000_000_000_000; let payable_account = make_payable_account_with_wallet_and_balance_and_timestamp_opt( recipient_wallet, - TEST_PAYMENT_AMOUNT, + payment_size_wei, None, ); @@ -1855,57 +1864,63 @@ mod tests { assert_eq!(byte_set_to_compare.as_slice(), template) } - //with a real confirmation through a transaction sent with this data to the network + // Transaction with this input was verified on the test network #[test] - fn web3_interface_signing_a_transaction_works_for_polygon_mumbai() { - let chain = Chain::PolyMumbai; - let nonce = 5; - // signed_transaction_data changed after we changed the contract address of polygon matic - let signed_transaction_data = "f8ad05850ba43b740083011980949b27034acabd44223fb23d628ba4849867ce1db280b844a9059cbb0000000000000000000000007788df76bbd9a0c7c3e5bf0f77bb28c60a167a7b000000000000000000000000000000000000000000000000000000e8d4a5100083027126a09fdbbd7064d3b7240f5422b2164aaa13d62f0946a683d82ee26f97f242570d90a077b49dbb408c20d73e0666ba0a77ac888bf7a9cb14824a5f35c97217b9bc0a5a"; - + fn web3_interface_signing_a_transaction_works_for_polygon_amoy() { + let chain = Chain::PolyAmoy; + let nonce = 4; + let signed_transaction_data = "\ + f8ad04850cce4166008301198094d98c3ebd6b7f9b7cda2449ecac00d1e5f47a819380b844a9059cbb000000000\ + 0000000000000007788df76bbd9a0c7c3e5bf0f77bb28c60a167a7b000000000000000000000000000000000000\ + 000000000000000000e8d4a5100083027127a0ddd78a41c42b7a409c281292f7c6aedefab8b461d87371fe402b4\ + b0804a092f2a04b1b599ac2c1ff07bb3d40d3698c454691c3b70d99f1e5d840c852e968c96a10"; let in_bytes = decode_hex(signed_transaction_data).unwrap(); assert_that_signed_transactions_agrees_with_template(chain, nonce, &in_bytes) } - //with a real confirmation through a transaction sent with this data to the network + // Transaction with this input was verified on the test network #[test] fn web3_interface_signing_a_transaction_works_for_eth_ropsten() { let chain = Chain::EthRopsten; - let nonce = 1; //must stay like this! - let signed_transaction_data = "f8a90185199c82cc0082dee894384dec25e03f94931767ce4c3556168468ba24c380b844a9059cbb0000000000000000000000007788df76bbd9a0c7c3e5bf0f77bb28c60a167a7b000000000000000000000000000000000000000000000000000000e8d4a510002aa0635fbb3652e1c3063afac6ffdf47220e0431825015aef7daff9251694e449bfca00b2ed6d556bd030ac75291bf58817da15a891cd027a4c261bb80b51f33b78adf"; + let nonce = 1; + let signed_transaction_data = "\ + f8a90185199c82cc0082dee894384dec25e03f94931767ce4c3556168468ba24c380b844a9059cbb00000000000\ + 00000000000007788df76bbd9a0c7c3e5bf0f77bb28c60a167a7b00000000000000000000000000000000000000\ + 0000000000000000e8d4a510002aa0635fbb3652e1c3063afac6ffdf47220e0431825015aef7daff9251694e449\ + bfca00b2ed6d556bd030ac75291bf58817da15a891cd027a4c261bb80b51f33b78adf"; let in_bytes = decode_hex(signed_transaction_data).unwrap(); assert_that_signed_transactions_agrees_with_template(chain, nonce, &in_bytes) } - //not confirmed on the real network + // Unconfirmed on the real network #[test] fn web3_interface_signing_a_transaction_for_polygon_mainnet() { let chain = Chain::PolyMainnet; let nonce = 10; - //generated locally + // Generated locally let signed_transaction_data = [ - 248, 172, 10, 133, 11, 164, 59, 116, 0, 131, 1, 25, 128, 148, 238, 154, 53, 47, 106, + 248, 172, 10, 133, 12, 206, 65, 102, 0, 131, 1, 25, 128, 148, 238, 154, 53, 47, 106, 172, 74, 241, 165, 185, 244, 103, 246, 169, 62, 15, 251, 233, 221, 53, 128, 184, 68, 169, 5, 156, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 119, 136, 223, 118, 187, 217, 160, 199, 195, 229, 191, 15, 119, 187, 40, 198, 10, 22, 122, 123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 212, 165, 16, 0, 130, - 1, 53, 160, 7, 203, 40, 44, 202, 233, 15, 5, 64, 218, 199, 239, 94, 126, 152, 2, 108, - 30, 157, 75, 124, 129, 117, 27, 109, 163, 132, 27, 11, 123, 137, 10, 160, 18, 170, 130, - 198, 73, 190, 158, 235, 0, 77, 118, 213, 244, 229, 225, 143, 156, 214, 219, 204, 193, - 155, 199, 164, 162, 31, 134, 51, 139, 130, 152, 104, + 1, 53, 160, 200, 159, 77, 202, 128, 195, 67, 122, 35, 204, 26, 65, 171, 89, 253, 82, 6, + 176, 192, 225, 41, 61, 151, 82, 66, 232, 72, 44, 68, 131, 140, 117, 160, 117, 66, 154, + 132, 183, 97, 219, 131, 214, 72, 220, 66, 152, 72, 15, 107, 44, 237, 193, 16, 193, 52, + 6, 94, 216, 149, 94, 102, 199, 80, 68, 105, ]; assert_that_signed_transactions_agrees_with_template(chain, nonce, &signed_transaction_data) } - //not confirmed on the real network + // Unconfirmed on the real network #[test] fn web3_interface_signing_a_transaction_for_eth_mainnet() { let chain = Chain::EthMainnet; let nonce = 10; - //generated locally + // Generated locally let signed_transaction_data = [ 248, 169, 10, 133, 25, 156, 130, 204, 0, 130, 222, 232, 148, 6, 243, 195, 35, 240, 35, 140, 114, 191, 53, 1, 16, 113, 242, 181, 183, 244, 58, 5, 76, 128, 184, 68, 169, 5, @@ -1921,8 +1936,8 @@ mod tests { assert_that_signed_transactions_agrees_with_template(chain, nonce, &signed_transaction_data) } - //an adapted test from old times when we had our own signing method - //I don't have data for the new chains so I omit them in this kind of tests + // Adapted test from old times when we had our own signing method. + // Don't have data for new chains, so I omit them in this kind of tests #[test] fn signs_various_transactions_for_eth_mainnet() { let signatures = &[ @@ -1955,8 +1970,8 @@ mod tests { assert_signature(Chain::EthMainnet, signatures) } - //an adapted test from old times when we had our own signing method - //I don't have data for the new chains so I omit them in this kind of tests + // Adapted test from old times when we had our own signing method. + // Don't have data for new chains, so I omit them in this kind of tests #[test] fn signs_various_transactions_for_ropsten() { let signatures = &[ diff --git a/node/src/blockchain/test_utils.rs b/node/src/blockchain/test_utils.rs index 4a8f4ecd6..16f7d21da 100644 --- a/node/src/blockchain/test_utils.rs +++ b/node/src/blockchain/test_utils.rs @@ -331,7 +331,7 @@ pub fn all_chains() -> [Chain; 4] { [ Chain::EthMainnet, Chain::PolyMainnet, - Chain::PolyMumbai, + Chain::PolyAmoy, Chain::Dev, ] } diff --git a/node/src/bootstrapper.rs b/node/src/bootstrapper.rs index 936babf77..358d21c40 100644 --- a/node/src/bootstrapper.rs +++ b/node/src/bootstrapper.rs @@ -1152,7 +1152,7 @@ mod tests { "--real-user", "123:456:/home/booga", "--chain", - "polygon-mumbai", + "polygon-amoy", ])) .unwrap(); diff --git a/node/src/daemon/mod.rs b/node/src/daemon/mod.rs index 78b8491e9..f16bcbc7f 100644 --- a/node/src/daemon/mod.rs +++ b/node/src/daemon/mod.rs @@ -161,7 +161,7 @@ impl Daemon { node_process_id: None, node_ui_port: None, verifier_tools: Box::new(VerifierToolsReal::new()), - setup_reporter: Box::new(SetupReporterReal::new(Box::new(DirsWrapperReal {}))), + setup_reporter: Box::new(SetupReporterReal::new(Box::new(DirsWrapperReal::default()))), logger: Logger::new("Daemon"), } } diff --git a/node/src/daemon/setup_reporter.rs b/node/src/daemon/setup_reporter.rs index d882ee773..303ecf373 100644 --- a/node/src/daemon/setup_reporter.rs +++ b/node/src/daemon/setup_reporter.rs @@ -742,7 +742,7 @@ impl ValueRetriever for DataDirectory { } impl std::default::Default for DataDirectory { fn default() -> Self { - Self::new(&DirsWrapperReal) + Self::new(&DirsWrapperReal::default()) } } impl DataDirectory { @@ -1136,7 +1136,7 @@ impl ValueRetriever for RealUser { } impl std::default::Default for RealUser { fn default() -> Self { - Self::new(&DirsWrapperReal {}) + Self::new(&DirsWrapperReal::default()) } } impl RealUser { @@ -1228,7 +1228,7 @@ mod tests { use core::option::Option; use dirs::home_dir; use masq_lib::blockchains::chains::Chain as Blockchain; - use masq_lib::blockchains::chains::Chain::PolyMumbai; + use masq_lib::blockchains::chains::Chain::PolyAmoy; use masq_lib::constants::{DEFAULT_CHAIN, DEFAULT_GAS_PRICE}; use masq_lib::messages::UiSetupResponseValueStatus::{Blank, Configured, Required, Set}; use masq_lib::test_utils::environment_guard::{ClapGuard, EnvironmentGuard}; @@ -1378,7 +1378,7 @@ mod tests { .into_iter() .map(|(name, value)| UiSetupRequestValue::new(name, value)) .collect_vec(); - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let result = subject @@ -1436,7 +1436,7 @@ mod tests { ( "real-user", &RealUser::new(None, None, None) - .populate(&DirsWrapperReal {}) + .populate(&DirsWrapperReal::default()) .to_string(), Default, ), @@ -1496,7 +1496,7 @@ mod tests { ("scan-intervals","150|150|150",Set), ("scans", "off", Set), ]); - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let result = subject.get_modified_setup(existing_setup, vec![]).unwrap(); @@ -1568,7 +1568,7 @@ mod tests { ].into_iter() .map (|(name, value)| UiSetupRequestValue::new(name, value)) .collect_vec(); - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let result = subject @@ -1643,7 +1643,7 @@ mod tests { ("MASQ_SCAN_INTERVALS","133|133|111") ].into_iter() .for_each (|(name, value)| std::env::set_var (name, value)); - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let params = vec![]; let subject = SetupReporterReal::new(dirs_wrapper); @@ -1956,7 +1956,7 @@ mod tests { ("scan-intervals", "111|111|111", Set), ("scans", "off", Set), ]); - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let result = subject.get_modified_setup(existing_setup, params).unwrap(); @@ -2264,14 +2264,10 @@ mod tests { let current_data_dir = base_dir .join("data_dir") .join("MASQ") - .join(BlockChain::PolyMumbai.rec().literal_identifier); //not a default + .join(BlockChain::PolyAmoy.rec().literal_identifier); //not a default let existing_setup = setup_cluster_from(vec![ ("blockchain-service-url", "", Required), - ( - "chain", - BlockChain::PolyMumbai.rec().literal_identifier, - Set, - ), + ("chain", BlockChain::PolyAmoy.rec().literal_identifier, Set), ("clandestine-port", "7788", Default), ("config-file", "config.toml", Default), ("consuming-private-key", "", Blank), @@ -2310,7 +2306,7 @@ mod tests { .get_modified_setup(existing_setup, incoming_setup) .unwrap_err(); - let expected_chain = PolyMumbai.rec().literal_identifier; + let expected_chain = PolyAmoy.rec().literal_identifier; let actual_chain = &resulting_setup_cluster.get("chain").unwrap().value; assert_eq!(actual_chain, expected_chain); let actual_data_directory = @@ -2338,7 +2334,7 @@ mod tests { ( "real-user", &crate::bootstrapper::RealUser::new(None, None, None) - .populate(&DirsWrapperReal {}) + .populate(&DirsWrapperReal::default()) .to_string(), Default, ), @@ -2347,7 +2343,7 @@ mod tests { .into_iter() .map(|(name, value)| UiSetupRequestValue::new(name, value)) .collect_vec(); - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let _ = subject @@ -2375,7 +2371,7 @@ mod tests { ), ]); let incoming_setup = vec![UiSetupRequestValue::clear("neighbors")]; - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let result = subject @@ -2487,7 +2483,7 @@ mod tests { let setup = setup_cluster_from(vec![]); let (real_user_opt, data_directory_opt, chain) = - SetupReporterReal::calculate_fundamentals(&DirsWrapperReal {}, &setup).unwrap(); + SetupReporterReal::calculate_fundamentals(&DirsWrapperReal::default(), &setup).unwrap(); assert_eq!( real_user_opt, @@ -2518,7 +2514,7 @@ mod tests { ]); let (real_user_opt, data_directory_opt, chain) = - SetupReporterReal::calculate_fundamentals(&DirsWrapperReal {}, &setup).unwrap(); + SetupReporterReal::calculate_fundamentals(&DirsWrapperReal::default(), &setup).unwrap(); assert_eq!( real_user_opt, @@ -2549,7 +2545,7 @@ mod tests { ]); let (real_user_opt, data_directory_opt, chain) = - SetupReporterReal::calculate_fundamentals(&DirsWrapperReal {}, &setup).unwrap(); + SetupReporterReal::calculate_fundamentals(&DirsWrapperReal::default(), &setup).unwrap(); assert_eq!( real_user_opt, @@ -2576,7 +2572,7 @@ mod tests { ]); let (real_user_opt, data_directory_opt, chain) = - SetupReporterReal::calculate_fundamentals(&DirsWrapperReal {}, &setup).unwrap(); + SetupReporterReal::calculate_fundamentals(&DirsWrapperReal::default(), &setup).unwrap(); assert_eq!( real_user_opt, @@ -2599,12 +2595,13 @@ mod tests { let setup = setup_cluster_from(vec![]); let (real_user_opt, data_directory_opt, chain) = - SetupReporterReal::calculate_fundamentals(&DirsWrapperReal {}, &setup).unwrap(); + SetupReporterReal::calculate_fundamentals(&DirsWrapperReal::default(), &setup).unwrap(); assert_eq!( real_user_opt, Some( - crate::bootstrapper::RealUser::new(None, None, None).populate(&DirsWrapperReal {}) + crate::bootstrapper::RealUser::new(None, None, None) + .populate(&DirsWrapperReal::default()) ) ); assert_eq!(data_directory_opt, None); @@ -2618,7 +2615,7 @@ mod tests { "setup_reporter", "blanking_a_parameter_with_a_default_produces_that_default", ); - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let result = subject @@ -2690,7 +2687,7 @@ mod tests { .into_iter() .map(|uisrv| (uisrv.name.clone(), uisrv)) .collect(); - let subject = SetupReporterReal::new(Box::new(DirsWrapperReal {})); + let subject = SetupReporterReal::new(Box::new(DirsWrapperReal::default())); let result = subject .calculate_configured_setup(&setup, &data_directory) @@ -2736,7 +2733,7 @@ mod tests { .map(|uisrv| (uisrv.name.clone(), uisrv)) .collect(); - let (result, _) = SetupReporterReal::new(Box::new(DirsWrapperReal {})) + let (result, _) = SetupReporterReal::new(Box::new(DirsWrapperReal::default())) .calculate_configured_setup(&setup, &*data_directory); assert_eq!(result.get("gas-price").unwrap().value, "10".to_string()); @@ -2757,7 +2754,7 @@ mod tests { } let setup = vec![ //no config-file setting - UiSetupResponseValue::new("chain", "polygon-mumbai", Set), + UiSetupResponseValue::new("chain", "polygon-amoy", Set), UiSetupResponseValue::new("neighborhood-mode", "zero-hop", Set), UiSetupResponseValue::new("config-file", "booga/special.toml", Set), UiSetupResponseValue::new( @@ -2769,7 +2766,7 @@ mod tests { .into_iter() .map(|uisrv| (uisrv.name.clone(), uisrv)) .collect(); - let subject = SetupReporterReal::new(Box::new(DirsWrapperReal {})); + let subject = SetupReporterReal::new(Box::new(DirsWrapperReal::default())); let result = subject .calculate_configured_setup(&setup, &data_directory) .0; @@ -2795,7 +2792,7 @@ mod tests { .into_iter() .map(|uisrv| (uisrv.name.clone(), uisrv)) .collect(); - let subject = SetupReporterReal::new(Box::new(DirsWrapperReal {})); + let subject = SetupReporterReal::new(Box::new(DirsWrapperReal::default())); let result = subject .calculate_configured_setup(&setup, &data_directory) @@ -2833,7 +2830,7 @@ mod tests { .into_iter() .map(|uisrv| (uisrv.name.clone(), uisrv)) .collect(); - let subject = SetupReporterReal::new(Box::new(DirsWrapperReal {})); + let subject = SetupReporterReal::new(Box::new(DirsWrapperReal::default())); let result = subject.calculate_configured_setup(&setup, &data_dir).0; @@ -2848,7 +2845,7 @@ mod tests { ); let config_file_dir = config_file_dir.canonicalize().unwrap(); let config_file_path = config_file_dir.join("nonexistent.toml"); - let wrapper = DirsWrapperReal {}; + let wrapper = DirsWrapperReal::default(); let data_directory = wrapper .data_dir() .unwrap() @@ -2866,7 +2863,7 @@ mod tests { .into_iter() .map(|uisrv| (uisrv.name.clone(), uisrv)) .collect(); - let subject = SetupReporterReal::new(Box::new(DirsWrapperReal {})); + let subject = SetupReporterReal::new(Box::new(DirsWrapperReal::default())); let result = subject .calculate_configured_setup(&setup, &data_directory) @@ -2919,11 +2916,14 @@ mod tests { #[test] fn data_directory_computed_default() { - let real_user = RealUser::new(None, None, None).populate(&DirsWrapperReal {}); - let expected = - data_directory_from_context(&DirsWrapperReal {}, &real_user, Blockchain::EthMainnet) - .to_string_lossy() - .to_string(); + let real_user = RealUser::new(None, None, None).populate(&DirsWrapperReal::default()); + let expected = data_directory_from_context( + &DirsWrapperReal::default(), + &real_user, + Blockchain::EthMainnet, + ) + .to_string_lossy() + .to_string(); let mut config = BootstrapperConfig::new(); config.real_user = real_user; config.blockchain_bridge_config.chain = Blockchain::from("eth-mainnet"); @@ -3317,7 +3317,7 @@ mod tests { result, Some(( RealUser::new(None, None, None) - .populate(&DirsWrapperReal {}) + .populate(&DirsWrapperReal::default()) .to_string(), Default )) @@ -3699,7 +3699,7 @@ mod tests { "data-directory", &masqhome.to_str().unwrap(), )]; - let dirs_wrapper = Box::new(DirsWrapperReal); + let dirs_wrapper = Box::new(DirsWrapperReal::default()); let subject = SetupReporterReal::new(dirs_wrapper); let result = subject.get_modified_setup(existing_setup, incoming_setup); @@ -3716,10 +3716,10 @@ mod tests { let _guard = EnvironmentGuard::new(); let existing_setup = setup_cluster_from(vec![("real-user", "1111:1111:/home/booga", Default)]); - let incoming_setup = vec![UiSetupRequestValue::new("chain", "polygon-mumbai")]; + let incoming_setup = vec![UiSetupRequestValue::new("chain", "polygon-amoy")]; let home_directory = Path::new("/home/booga"); let data_directory = home_directory.join("data"); - let expected = data_directory.join("MASQ").join("polygon-mumbai"); + let expected = data_directory.join("MASQ").join("polygon-amoy"); let dirs_wrapper = Box::new( DirsWrapperMock::new() .data_dir_result(Some(data_directory)) diff --git a/node/src/database/config_dumper.rs b/node/src/database/config_dumper.rs index 891eac1ad..78f23ade7 100644 --- a/node/src/database/config_dumper.rs +++ b/node/src/database/config_dumper.rs @@ -198,7 +198,7 @@ mod tests { .opt("--dump-config") .into(); let subject = DumpConfigRunnerReal { - dirs_wrapper: Box::new(DirsWrapperReal), + dirs_wrapper: Box::new(DirsWrapperReal::default()), }; let caught_panic = catch_unwind(AssertUnwindSafe(|| { @@ -239,7 +239,7 @@ mod tests { .opt("--dump-config") .into(); let subject = DumpConfigRunnerReal { - dirs_wrapper: Box::new(DirsWrapperReal), + dirs_wrapper: Box::new(DirsWrapperReal::default()), }; let result = subject.go(&mut holder.streams(), args_vec.as_slice()); @@ -471,7 +471,7 @@ mod tests { .opt("--dump-config") .into(); let subject = DumpConfigRunnerReal { - dirs_wrapper: Box::new(DirsWrapperReal), + dirs_wrapper: Box::new(DirsWrapperReal::default()), }; let result = subject.go(&mut holder.streams(), args_vec.as_slice()); @@ -579,7 +579,7 @@ mod tests { .opt("--dump-config") .into(); let subject = DumpConfigRunnerReal { - dirs_wrapper: Box::new(DirsWrapperReal), + dirs_wrapper: Box::new(DirsWrapperReal::default()), }; let result = subject.go(&mut holder.streams(), args_vec.as_slice()); diff --git a/node/src/node_configurator/mod.rs b/node/src/node_configurator/mod.rs index a45a2969a..135d3b20f 100644 --- a/node/src/node_configurator/mod.rs +++ b/node/src/node_configurator/mod.rs @@ -305,7 +305,7 @@ pub trait DirsWrapper: Send { fn dup(&self) -> Box; // because implementing Clone for traits is problematic. } -pub struct DirsWrapperReal; +pub struct DirsWrapperReal {} impl DirsWrapper for DirsWrapperReal { fn data_dir(&self) -> Option { @@ -315,7 +315,19 @@ impl DirsWrapper for DirsWrapperReal { home_dir() } fn dup(&self) -> Box { - Box::new(DirsWrapperReal) + Box::new(DirsWrapperReal::default()) + } +} + +impl DirsWrapperReal { + pub fn new() -> Self { + Self {} + } +} + +impl Default for DirsWrapperReal { + fn default() -> Self { + DirsWrapperReal::new() } } @@ -348,7 +360,7 @@ mod tests { "/nonexistent_home/nonexistent_alice".to_string(), )), ); - let chain_name = "polygon-mumbai"; + let chain_name = "polygon-amoy"; let result = data_directory_from_context(&dirs_wrapper, &real_user, Chain::from(chain_name)); @@ -356,7 +368,7 @@ mod tests { assert_eq!( result, PathBuf::from( - "/nonexistent_home/nonexistent_alice/.local/share/MASQ/polygon-mumbai".to_string() + "/nonexistent_home/nonexistent_alice/.local/share/MASQ/polygon-amoy".to_string() ) ) } @@ -377,7 +389,8 @@ mod tests { let args_vec: Vec = args.into(); let app = determine_config_file_path_app(); let user_specific_data = - determine_user_specific_data(&DirsWrapperReal {}, &app, args_vec.as_slice()).unwrap(); + determine_user_specific_data(&DirsWrapperReal::default(), &app, args_vec.as_slice()) + .unwrap(); assert_eq!( &format!( @@ -418,7 +431,8 @@ mod tests { std::env::set_var("MASQ_CONFIG_FILE", "booga.toml"); let app = determine_config_file_path_app(); let user_specific_data = - determine_user_specific_data(&DirsWrapperReal {}, &app, args_vec.as_slice()).unwrap(); + determine_user_specific_data(&DirsWrapperReal::default(), &app, args_vec.as_slice()) + .unwrap(); assert_eq!( format!( "{}", @@ -454,7 +468,8 @@ mod tests { let app = determine_config_file_path_app(); let user_specific_data = - determine_user_specific_data(&DirsWrapperReal {}, &app, args_vec.as_slice()).unwrap(); + determine_user_specific_data(&DirsWrapperReal::default(), &app, args_vec.as_slice()) + .unwrap(); assert_eq!( "/tmp/booga.toml", @@ -474,7 +489,7 @@ mod tests { let args_vec: Vec = args.into(); let user_specific_data = determine_user_specific_data( - &DirsWrapperReal {}, + &DirsWrapperReal::default(), &determine_config_file_path_app(), args_vec.as_slice(), ) @@ -498,7 +513,7 @@ mod tests { let args_vec: Vec = args.into(); let user_specific_data = determine_user_specific_data( - &DirsWrapperReal {}, + &DirsWrapperReal::default(), &determine_config_file_path_app(), args_vec.as_slice(), ) @@ -521,7 +536,7 @@ mod tests { let args_vec: Vec = args.into(); let user_specific_data = determine_user_specific_data( - &DirsWrapperReal {}, + &DirsWrapperReal::default(), &determine_config_file_path_app(), args_vec.as_slice(), ) @@ -545,7 +560,7 @@ mod tests { let args_vec: Vec = args.into(); let user_specific_data = determine_user_specific_data( - &DirsWrapperReal {}, + &DirsWrapperReal::default(), &determine_config_file_path_app(), args_vec.as_slice(), ) diff --git a/node/src/node_configurator/node_configurator_standard.rs b/node/src/node_configurator/node_configurator_standard.rs index bb930a9d1..6038a1990 100644 --- a/node/src/node_configurator/node_configurator_standard.rs +++ b/node/src/node_configurator/node_configurator_standard.rs @@ -63,7 +63,7 @@ impl Default for NodeConfiguratorStandardPrivileged { impl NodeConfiguratorStandardPrivileged { pub fn new() -> Self { Self { - dirs_wrapper: Box::new(DirsWrapperReal {}), + dirs_wrapper: Box::new(DirsWrapperReal::default()), } } } @@ -597,8 +597,12 @@ mod tests { ) .unwrap(); - privileged_parse_args(&DirsWrapperReal {}, &multi_config, &mut bootstrapper_config) - .unwrap(); + privileged_parse_args( + &DirsWrapperReal::default(), + &multi_config, + &mut bootstrapper_config, + ) + .unwrap(); let node_parse_args_configurator = UnprivilegedParseArgsConfigurationDaoNull {}; node_parse_args_configurator .unprivileged_parse_args( @@ -660,13 +664,13 @@ mod tests { "ABCDEF01ABCDEF01ABCDEF01ABCDEF01ABCDEF01ABCDEF01ABCDEF01ABCDEF01", ) .param("--real-user", "999:999:/home/booga") - .param("--chain", "polygon-mumbai"); + .param("--chain", "polygon-amoy"); let mut config = BootstrapperConfig::new(); let vcls: Vec> = vec![Box::new(CommandLineVcl::new(args.into()))]; let multi_config = make_new_multi_config(&app_node(), vcls).unwrap(); - privileged_parse_args(&DirsWrapperReal {}, &multi_config, &mut config).unwrap(); + privileged_parse_args(&DirsWrapperReal::default(), &multi_config, &mut config).unwrap(); assert_eq!( value_m!(multi_config, "config-file", PathBuf), @@ -711,7 +715,7 @@ mod tests { vec![Box::new(CommandLineVcl::new(args.into()))]; let multi_config = make_new_multi_config(&app_node(), vcls).unwrap(); - privileged_parse_args(&DirsWrapperReal {}, &multi_config, &mut config).unwrap(); + privileged_parse_args(&DirsWrapperReal::default(), &multi_config, &mut config).unwrap(); assert_eq!(None, value_m!(multi_config, "config-file", PathBuf)); assert_eq!( @@ -723,7 +727,7 @@ mod tests { assert!(config.main_cryptde_null_opt.is_none()); assert_eq!( config.real_user, - RealUser::new(None, None, None).populate(&DirsWrapperReal {}) + RealUser::new(None, None, None).populate(&DirsWrapperReal::default()) ); } @@ -739,7 +743,7 @@ mod tests { vec![Box::new(CommandLineVcl::new(args.into()))]; let multi_config = make_new_multi_config(&app_node(), vcls).unwrap(); - privileged_parse_args(&DirsWrapperReal {}, &multi_config, &mut config).unwrap(); + privileged_parse_args(&DirsWrapperReal::default(), &multi_config, &mut config).unwrap(); #[cfg(target_os = "linux")] assert_eq!( @@ -765,7 +769,7 @@ mod tests { vec![Box::new(CommandLineVcl::new(args.into()))]; let multi_config = make_new_multi_config(&app_node(), vcls).unwrap(); - privileged_parse_args(&DirsWrapperReal {}, &multi_config, &mut config).unwrap(); + privileged_parse_args(&DirsWrapperReal::default(), &multi_config, &mut config).unwrap(); assert_eq!(None, value_m!(multi_config, "config-file", PathBuf)); assert_eq!( @@ -777,7 +781,7 @@ mod tests { assert!(config.main_cryptde_null_opt.is_none()); assert_eq!( config.real_user, - RealUser::new(None, None, None).populate(&DirsWrapperReal {}) + RealUser::new(None, None, None).populate(&DirsWrapperReal::default()) ); } @@ -789,7 +793,7 @@ mod tests { let vcl = Box::new(CommandLineVcl::new(args.into())); let multi_config = make_new_multi_config(&app_node(), vec![vcl]).unwrap(); - privileged_parse_args(&DirsWrapperReal {}, &multi_config, &mut config).unwrap(); + privileged_parse_args(&DirsWrapperReal::default(), &multi_config, &mut config).unwrap(); assert_eq!(config.crash_point, CrashPoint::None); } @@ -802,7 +806,7 @@ mod tests { let vcl = Box::new(CommandLineVcl::new(args.into())); let multi_config = make_new_multi_config(&app_node(), vec![vcl]).unwrap(); - privileged_parse_args(&DirsWrapperReal {}, &multi_config, &mut config).unwrap(); + privileged_parse_args(&DirsWrapperReal::default(), &multi_config, &mut config).unwrap(); assert_eq!(config.crash_point, CrashPoint::Panic); } @@ -1020,8 +1024,8 @@ mod tests { ); let home_dir = canonicalize(home_dir).unwrap(); let data_dir = &home_dir.join("data_dir"); - let config_file_relative = File::create(home_dir.join("config.toml")).unwrap(); - fill_up_config_file(config_file_relative); + let config_file = File::create(home_dir.join("config.toml")).unwrap(); + fill_up_config_file(config_file); let env_vec_array = vec![ ( "MASQ_CONFIG_FILE", @@ -1185,7 +1189,6 @@ mod tests { let _guard = EnvironmentGuard::new(); let _clap_guard = ClapGuard::new(); let home_dir = ensure_node_home_directory_exists( "node_configurator_standard","server_initializer_collected_params_fails_on_naked_dir_config_file_without_data_directory"); - let data_dir = &home_dir.join("data_dir"); vec![("MASQ_CONFIG_FILE", "config/config.toml")] .into_iter() @@ -1210,9 +1213,7 @@ mod tests { ); let data_dir = &home_dir.join("data_dir"); let config_file = File::create(&home_dir.join("booga.toml")).unwrap(); - let current_directory = current_dir().unwrap(); fill_up_config_file(config_file); - let env_vec_array = vec![ ("MASQ_CONFIG_FILE", "booga.toml"), ("MASQ_CLANDESTINE_PORT", "8888"), @@ -1229,7 +1230,10 @@ mod tests { .home_dir_result(Some(home_dir.clone())) .data_dir_result(Some(data_dir.to_path_buf())); let args = ArgsBuilder::new() - .param("--data-directory", current_directory.join(Path::new("generated/test/node_configurator_standard/server_initializer_collected_params_combine_vcls_properly/home")).to_string_lossy().to_string().as_str()) + .param( + "--data-directory", + home_dir.to_string_lossy().to_string().as_str(), + ) .param("--clandestine-port", "1111") .param("--real-user", "1001:1001:cooga"); let args_vec: Vec = args.into(); @@ -1249,22 +1253,17 @@ mod tests { value_m!(multiconfig, "ip", String).unwrap(), "6.6.6.6".to_string() ); + assert_eq!( + value_m!(multiconfig, "config-file", String).unwrap(), + home_dir.join("booga.toml").as_os_str().to_str().unwrap() + ); #[cfg(not(target_os = "windows"))] { - assert_eq!( - value_m!(multiconfig, "config-file", String).unwrap(), - current_directory.join("generated/test/node_configurator_standard/server_initializer_collected_params_combine_vcls_properly/home/booga.toml").to_string_lossy().to_string() - ); assert_eq!( value_m!(multiconfig, "real-user", String).unwrap(), "1001:1001:cooga".to_string() ); } - #[cfg(target_os = "windows")] - assert_eq!( - value_m!(multiconfig, "config-file", String).unwrap(), - current_directory.join("generated/test/node_configurator_standard/server_initializer_collected_params_combine_vcls_properly/home\\booga.toml").to_string_lossy().to_string() - ); } #[test] @@ -1611,30 +1610,30 @@ mod tests { running_test(); let home_dir = Path::new("/home/cooga"); let home_dir_poly_main = home_dir.join(".local").join("MASQ").join("polygon-mainnet"); - let home_dir_poly_mumbai = home_dir.join(".local").join("MASQ").join("polygon-mumbai"); + let home_dir_poly_amoy = home_dir.join(".local").join("MASQ").join("polygon-amoy"); vec![ (None, None, Some(home_dir_poly_main.to_str().unwrap())), ( - Some("polygon-mumbai"), + Some("polygon-amoy"), None, - Some(home_dir_poly_mumbai.to_str().unwrap()), + Some(home_dir_poly_amoy.to_str().unwrap()), ), (None, Some("/cooga"), Some("/cooga")), - (Some("polygon-mumbai"), Some("/cooga"), Some("/cooga")), + (Some("polygon-amoy"), Some("/cooga"), Some("/cooga")), ( None, - Some("/cooga/polygon-mumbai"), - Some("/cooga/polygon-mumbai"), + Some("/cooga/polygon-amoy"), + Some("/cooga/polygon-amoy"), ), ( None, - Some("/cooga/polygon-mumbai/polygon-mainnet"), - Some("/cooga/polygon-mumbai/polygon-mainnet"), + Some("/cooga/polygon-amoy/polygon-mainnet"), + Some("/cooga/polygon-amoy/polygon-mainnet"), ), ( - Some("polygon-mumbai"), - Some("/cooga/polygon-mumbai"), - Some("/cooga/polygon-mumbai"), + Some("polygon-amoy"), + Some("/cooga/polygon-amoy"), + Some("/cooga/polygon-amoy"), ), ] .iter() diff --git a/node/src/privilege_drop.rs b/node/src/privilege_drop.rs index 1eba9cf88..2b4d8e198 100644 --- a/node/src/privilege_drop.rs +++ b/node/src/privilege_drop.rs @@ -190,7 +190,9 @@ mod tests { let mut subject = PrivilegeDropperReal::new(); subject.id_wrapper = Box::new(id_wrapper); - subject.drop_privileges(&RealUser::new(None, None, None).populate(&DirsWrapperReal {})); + subject.drop_privileges( + &RealUser::new(None, None, None).populate(&DirsWrapperReal::default()), + ); } #[cfg(not(target_os = "windows"))] @@ -283,7 +285,9 @@ mod tests { let mut subject = PrivilegeDropperReal::new(); subject.id_wrapper = Box::new(id_wrapper); - subject.drop_privileges(&RealUser::new(None, None, None).populate(&DirsWrapperReal {})); + subject.drop_privileges( + &RealUser::new(None, None, None).populate(&DirsWrapperReal::default()), + ); let setuid_params = setuid_params_arc.lock().unwrap(); assert!(setuid_params.is_empty()); diff --git a/node/src/run_modes_factories.rs b/node/src/run_modes_factories.rs index 61a3294ba..c3c009438 100644 --- a/node/src/run_modes_factories.rs +++ b/node/src/run_modes_factories.rs @@ -82,7 +82,7 @@ pub trait DaemonInitializer { impl DumpConfigRunnerFactory for DumpConfigRunnerFactoryReal { fn make(&self) -> Box { Box::new(DumpConfigRunnerReal { - dirs_wrapper: Box::new(DirsWrapperReal), + dirs_wrapper: Box::new(DirsWrapperReal::default()), }) } } @@ -111,7 +111,7 @@ impl DaemonInitializerFactory for DaemonInitializerFactoryReal { impl Default for DIClusteredParams { fn default() -> Self { Self { - dirs_wrapper: Box::new(DirsWrapperReal), + dirs_wrapper: Box::new(DirsWrapperReal::default()), logger_initializer_wrapper: Box::new(LoggerInitializerWrapperReal), channel_factory: Box::new(ChannelFactoryReal::new()), recipients_factory: Box::new(RecipientsFactoryReal::new()), diff --git a/node/src/server_initializer.rs b/node/src/server_initializer.rs index 048e8d6fa..2f2c5f320 100644 --- a/node/src/server_initializer.rs +++ b/node/src/server_initializer.rs @@ -94,7 +94,7 @@ impl Default for ServerInitializerReal { dns_socket_server: Box::new(DnsSocketServer::new()), bootstrapper: Box::new(Bootstrapper::new(Box::new(LoggerInitializerWrapperReal {}))), privilege_dropper: Box::new(PrivilegeDropperReal::new()), - dirs_wrapper: Box::new(DirsWrapperReal), + dirs_wrapper: Box::new(DirsWrapperReal::default()), } } } diff --git a/node/src/sub_lib/neighborhood.rs b/node/src/sub_lib/neighborhood.rs index 64c30c2fe..24bc2d459 100644 --- a/node/src/sub_lib/neighborhood.rs +++ b/node/src/sub_lib/neighborhood.rs @@ -716,12 +716,12 @@ mod tests { } #[test] - fn parse_works_for_mumbai() { - let descriptor = "masq://polygon-mumbai:as45cs5c5@1.2.3.4:4444"; + fn parse_works_for_amoy() { + let descriptor = "masq://polygon-amoy:as45cs5c5@1.2.3.4:4444"; let result = NodeDescriptor::parse_url(descriptor).unwrap(); - assert_eq!(result, (Chain::PolyMumbai, "as45cs5c5", "1.2.3.4:4444")) + assert_eq!(result, (Chain::PolyAmoy, "as45cs5c5", "1.2.3.4:4444")) } #[test] @@ -748,7 +748,7 @@ mod tests { assert_eq!( result, Err( - "Chain identifier 'bitcoin' is not valid; possible values are 'polygon-mainnet', 'eth-mainnet', 'polygon-mumbai', 'eth-ropsten' while formatted as 'masq://:@'" + "Chain identifier 'bitcoin' is not valid; possible values are 'polygon-mainnet', 'eth-mainnet', 'polygon-amoy', 'eth-ropsten' while formatted as 'masq://:@'" .to_string() ) ); @@ -847,7 +847,7 @@ mod tests { let result = DescriptorParsingError::WrongChainIdentifier("blah").to_string(); - assert_eq!(result, "Chain identifier 'blah' is not valid; possible values are 'polygon-mainnet', 'eth-mainnet', 'polygon-mumbai', 'eth-ropsten' while formatted as 'masq://:@'") + assert_eq!(result, "Chain identifier 'blah' is not valid; possible values are 'polygon-mainnet', 'eth-mainnet', 'polygon-amoy', 'eth-ropsten' while formatted as 'masq://:@'") } #[test] diff --git a/node/src/test_utils/mod.rs b/node/src/test_utils/mod.rs index 60a9b7741..22bdf672e 100644 --- a/node/src/test_utils/mod.rs +++ b/node/src/test_utils/mod.rs @@ -516,7 +516,7 @@ pub fn assert_eq_debug(a: T, b: T) { assert_eq!(a_str, b_str); } -//must stay without cfg(test) -- used in another crate +// Must stay without cfg(test) -- used in another crate #[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)] pub struct TestRawTransaction { pub nonce: U256, diff --git a/node/tests/contract_test.rs b/node/tests/contract_test.rs index 6002f392b..8e9e74395 100644 --- a/node/tests/contract_test.rs +++ b/node/tests/contract_test.rs @@ -105,14 +105,13 @@ where } #[test] -fn masq_erc20_contract_exists_on_polygon_mumbai_integration() { +fn masq_erc20_contract_exists_on_polygon_amoy_integration() { let blockchain_urls = vec![ - "https://rpc-mumbai.polygon.technology", - "https://matic-mumbai.chainstacklabs.com", - "https://rpc-mumbai.maticvigil.com", - "https://matic-testnet-archive-rpc.bwarelabs.com", + "https://rpc-amoy.polygon.technology", + "https://rpc.ankr.com/polygon_amoy", + "https://80002.rpc.thirdweb.com", ]; - let chain = Chain::PolyMumbai; + let chain = Chain::PolyAmoy; let assertion_body = |url, chain| assert_contract_existence(url, chain, "tMASQ", 18); assert_contract(blockchain_urls, &chain, assertion_body) diff --git a/node/tests/dump_configuration_test.rs b/node/tests/dump_configuration_test.rs index 044eb2043..62a045b0d 100644 --- a/node/tests/dump_configuration_test.rs +++ b/node/tests/dump_configuration_test.rs @@ -22,7 +22,7 @@ fn dump_configuration_with_an_existing_database_integration() { Some( CommandConfig::new() .pair("--ui-port", &port.to_string()) - .pair("--chain", "polygon-mumbai"), + .pair("--chain", "polygon-amoy"), ), true, true, @@ -38,7 +38,7 @@ fn dump_configuration_with_an_existing_database_integration() { let mut node = utils::MASQNode::run_dump_config( test_name, - Some(CommandConfig::new().pair("--chain", "polygon-mumbai")), + Some(CommandConfig::new().pair("--chain", "polygon-amoy")), false, true, true, diff --git a/node/tests/node_exits_from_future_panic_test.rs b/node/tests/node_exits_from_future_panic_test.rs index 1419dc0fe..dc3ec25ab 100644 --- a/node/tests/node_exits_from_future_panic_test.rs +++ b/node/tests/node_exits_from_future_panic_test.rs @@ -67,7 +67,7 @@ const STAT_FORMAT_PARAM_NAME: &str = "-f"; fn node_logfile_does_not_belong_to_root_integration() { let mut node = MASQNode::start_standard( "node_logfile_does_not_belong_to_root_integration", - Some(CommandConfig::new().pair("--chain", "polygon-mumbai")), + Some(CommandConfig::new().pair("--chain", "polygon-amoy")), true, true, false,