Skip to content

Commit

Permalink
Improve test exit config parsing
Browse files Browse the repository at this point in the history
This patch improves the creation of the exit config in the test
environment, removing redundant writing out to the disk and removing
duplicate default specifications.
  • Loading branch information
jkilpatr committed Nov 21, 2023
1 parent 9019b81 commit 47534ae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 192 deletions.
176 changes: 0 additions & 176 deletions integration_tests/src/config.rs

This file was deleted.

1 change: 0 additions & 1 deletion integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ extern crate log;

use std::time::Duration;

pub mod config;
pub mod contract_test;
pub mod db_migration_test;
pub mod debts;
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/src/setup_utils/rita.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ pub fn spawn_rita_exit(
) -> Identity {
let ns_dup = ns.clone();
let wg_keypath = format!("/var/tmp/{ns}");
let wg_keypath_exit = format!("/var/tmp/{ns}-exit");
let config_path = format!("/var/tmp/settings-{ns}.toml");
// thread safe lock that allows us to pass data between the router thread and this thread
// one copy of the reference is sent into the closure and the other is kept in this scope.
Expand Down Expand Up @@ -237,7 +238,10 @@ pub fn spawn_rita_exit(
resettings.exit_network.registered_users_contract_addr = db_addr;
resettings.network.wg_private_key = Some(instance.wg_priv_key);
resettings.network.wg_public_key = Some(instance.exit_id.wg_public_key);
resettings.exit_network.wg_private_key = instance.wg_priv_key;
resettings.exit_network.wg_public_key = instance.exit_id.wg_public_key;
resettings.network.wg_private_key_path = wg_keypath;
resettings.exit_network.wg_private_key_path = wg_keypath_exit;
resettings.network.peer_interfaces = veth_interfaces;
resettings.payment.local_fee = local_fee;
resettings.payment.eth_private_key = Some(instance.eth_private_key);
Expand Down
23 changes: 16 additions & 7 deletions integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{
config::{CONFIG_FILE_PATH, EXIT_CONFIG_PATH},
payments_althea::get_althea_evm_priv,
payments_eth::{eth_chain_id, get_eth_miner_key, get_miner_address, ONE_ETH, WEB3_TIMEOUT},
setup_utils::{
Expand Down Expand Up @@ -36,7 +35,7 @@ use rita_common::{
debt_keeper::GetDebtsResult,
payment_validator::{ALTHEA_CHAIN_PREFIX, ALTHEA_CONTACT_TIMEOUT},
};
use settings::{client::RitaClientSettings, exit::RitaExitSettingsStruct};
use settings::{client::RitaClientSettings, exit::{RitaExitSettingsStruct, ExitNetworkSettings}, payment::PaymentSettings, localization::LocalizationSettings, network::NetworkSettings};
use std::{
collections::{HashMap, HashSet},
net::Ipv6Addr,
Expand Down Expand Up @@ -359,15 +358,25 @@ pub const EXIT_ROOT_IP: IpAddr =
// this masks public ipv6 ips in the test env and is being used to test assignment
pub const EXIT_SUBNET: Ipv6Addr = Ipv6Addr::new(0xfbad, 200, 0, 0, 0, 0, 0, 0);

/// Gets the default client and exit settings handling the pre-launch exchange of exit into and its insertion into
/// the
/// Gets the default client and exit settings
pub fn get_default_settings(
namespaces: NamespaceInfo,
) -> (RitaClientSettings, RitaExitSettingsStruct) {
let exit = RitaExitSettingsStruct::new(EXIT_CONFIG_PATH).unwrap();
let client = RitaClientSettings::new(CONFIG_FILE_PATH).unwrap();

let mut exit_servers = HashMap::new();
let exit = RitaExitSettingsStruct {
db_uri: "postgres://postgres@localhost/test".to_string(),
client_registration_url: "https://7.7.7.1:40400/register_router".to_string(),
workers: 2,
remote_log: false,
description: "Test environment exit instance".to_string(),
payment: PaymentSettings::default(),
localization: LocalizationSettings::default(),
network: NetworkSettings::default(),
exit_network: ExitNetworkSettings::test_default(),
allowed_countries: HashSet::new(),
save_interval: 6000,
};
let client = RitaClientSettings::default();

let mut exit_mesh_ips = HashSet::new();
for ns in namespaces.names {
Expand Down
8 changes: 0 additions & 8 deletions test_runner/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use integration_tests::config::{
generate_exit_config_file, generate_rita_config_file, CONFIG_FILE_PATH, EXIT_CONFIG_PATH,
};
use integration_tests::contract_test::run_altheadb_contract_test;
use integration_tests::db_migration_test::run_db_migration_test;
use integration_tests::debts::run_debts_test;
Expand Down Expand Up @@ -36,11 +33,6 @@ async fn main() {

println!("Starting the Rita test runner");

let conf = generate_rita_config_file(CONFIG_FILE_PATH.to_string());
info!("Generating rita config file: {:?}", conf);
let conf = generate_exit_config_file(EXIT_CONFIG_PATH.to_string());
info!("Generating exit config file: {:?}", conf);

let test_type = env::var("TEST_TYPE");
info!("Starting tests with {:?}", test_type);
if let Ok(test_type) = test_type {
Expand Down

0 comments on commit 47534ae

Please sign in to comment.