From 98907d39a2b95d9352fc342327fa63c3029c39f3 Mon Sep 17 00:00:00 2001 From: Pranay Tulugu Date: Wed, 13 Sep 2023 11:15:54 -0700 Subject: [PATCH] Fix CI tests and general cleanup --- .github/workflows/rust.yml | 11 +++++- Cargo.lock | 18 --------- Cargo.toml | 1 - exit_db/Cargo.toml | 13 ------- exit_db/diesel.toml | 5 --- .../down.sql | 6 --- .../up.sql | 36 ----------------- .../2019-02-22-214628_rita-setup/down.sql | 2 - .../2019-02-22-214628_rita-setup/up.sql | 18 --------- .../2022-05-18-184145_ipv6_migration/down.sql | 5 --- .../2022-05-18-184145_ipv6_migration/up.sql | 10 ----- .../down.sql | 4 -- .../up.sql | 4 -- exit_db/src/lib.rs | 7 ---- exit_db/src/models.rs | 38 ------------------ exit_db/src/schema.rs | 28 ------------- integration_tests/src/contract_test.rs | 8 +++- integration_tests/src/debts.rs | 35 +++++++++++++---- integration_tests/src/five_nodes.rs | 13 +++++-- integration_tests/src/mutli_exit.rs | 36 ++++++++++++++--- integration_tests/src/payments_althea.rs | 35 ++++++++++++++--- integration_tests/src/payments_eth.rs | 39 +++++++++++++------ rita_client/src/exit_manager/mod.rs | 1 - rita_client_registration/src/lib.rs | 13 +------ rita_exit/src/rita_loop/mod.rs | 2 - settings/example_exit.toml | 1 + settings/test_exit.toml | 1 + test_runner/src/main.rs | 8 ---- 28 files changed, 144 insertions(+), 254 deletions(-) delete mode 100644 exit_db/Cargo.toml delete mode 100644 exit_db/diesel.toml delete mode 100644 exit_db/migrations/00000000000000_diesel_initial_setup/down.sql delete mode 100644 exit_db/migrations/00000000000000_diesel_initial_setup/up.sql delete mode 100644 exit_db/migrations/2019-02-22-214628_rita-setup/down.sql delete mode 100644 exit_db/migrations/2019-02-22-214628_rita-setup/up.sql delete mode 100644 exit_db/migrations/2022-05-18-184145_ipv6_migration/down.sql delete mode 100644 exit_db/migrations/2022-05-18-184145_ipv6_migration/up.sql delete mode 100644 exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/down.sql delete mode 100644 exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/up.sql delete mode 100644 exit_db/src/lib.rs delete mode 100644 exit_db/src/models.rs delete mode 100644 exit_db/src/schema.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ccc1a885..d392d43f4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -144,4 +144,13 @@ jobs: - name: Install Wireguard run: sudo apt-get update && sudo apt install -y wireguard linux-source linux-headers-$(uname -r) build-essential && sudo modprobe wireguard - name: Run integration test - run: bash scripts/integration_tests/all-up-test.sh MULTI_EXIT \ No newline at end of file + run: bash scripts/integration_tests/all-up-test.sh MULTI_EXIT + integration-test-validate-contract: + needs: integration-test-five-nodes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Wireguard + run: sudo apt-get update && sudo apt install -y wireguard linux-source linux-headers-$(uname -r) build-essential && sudo modprobe wireguard + - name: Run integration test + run: bash scripts/integration_tests/all-up-test.sh CONTRACT_TEST \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 0bf160cdd..5ff30d846 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1047,12 +1047,6 @@ dependencies = [ "strsim", ] -[[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - [[package]] name = "ed25519" version = "1.5.3" @@ -1133,18 +1127,6 @@ dependencies = [ "libc", ] -[[package]] -name = "exit_db" -version = "0.1.0" -dependencies = [ - "althea_types", - "diesel", - "dotenv", - "serde", - "serde_derive", - "serde_json", -] - [[package]] name = "fastrand" version = "1.9.0" diff --git a/Cargo.toml b/Cargo.toml index b3eac0262..0dc588d9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ members = [ "althea_kernel_interface", "settings", "clu", - "exit_db", "antenna_forwarding_client", "antenna_forwarding_protocol", "auto_bridge", diff --git a/exit_db/Cargo.toml b/exit_db/Cargo.toml deleted file mode 100644 index a519fedc1..000000000 --- a/exit_db/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "exit_db" -version = "0.1.0" -authors = ["Ben "] -edition = "2018" - -[dependencies] -diesel = { version = "1.4", features = ["postgres"] } -dotenv = "0.15" -althea_types = { path = "../althea_types"} -serde = "1.0" -serde_derive = "1.0" -serde_json = "1.0" diff --git a/exit_db/diesel.toml b/exit_db/diesel.toml deleted file mode 100644 index 92267c829..000000000 --- a/exit_db/diesel.toml +++ /dev/null @@ -1,5 +0,0 @@ -# For documentation on how to configure this file, -# see diesel.rs/guides/configuring-diesel-cli - -[print_schema] -file = "src/schema.rs" diff --git a/exit_db/migrations/00000000000000_diesel_initial_setup/down.sql b/exit_db/migrations/00000000000000_diesel_initial_setup/down.sql deleted file mode 100644 index a9f526091..000000000 --- a/exit_db/migrations/00000000000000_diesel_initial_setup/down.sql +++ /dev/null @@ -1,6 +0,0 @@ --- This file was automatically created by Diesel to setup helper functions --- and other internal bookkeeping. This file is safe to edit, any future --- changes will be added to existing projects as new migrations. - -DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass); -DROP FUNCTION IF EXISTS diesel_set_updated_at(); diff --git a/exit_db/migrations/00000000000000_diesel_initial_setup/up.sql b/exit_db/migrations/00000000000000_diesel_initial_setup/up.sql deleted file mode 100644 index d68895b1a..000000000 --- a/exit_db/migrations/00000000000000_diesel_initial_setup/up.sql +++ /dev/null @@ -1,36 +0,0 @@ --- This file was automatically created by Diesel to setup helper functions --- and other internal bookkeeping. This file is safe to edit, any future --- changes will be added to existing projects as new migrations. - - - - --- Sets up a trigger for the given table to automatically set a column called --- `updated_at` whenever the row is modified (unless `updated_at` was included --- in the modified columns) --- --- # Example --- --- ```sql --- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW()); --- --- SELECT diesel_manage_updated_at('users'); --- ``` -CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$ -BEGIN - EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s - FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl); -END; -$$ LANGUAGE plpgsql; - -CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$ -BEGIN - IF ( - NEW IS DISTINCT FROM OLD AND - NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at - ) THEN - NEW.updated_at := current_timestamp; - END IF; - RETURN NEW; -END; -$$ LANGUAGE plpgsql; diff --git a/exit_db/migrations/2019-02-22-214628_rita-setup/down.sql b/exit_db/migrations/2019-02-22-214628_rita-setup/down.sql deleted file mode 100644 index 036a199de..000000000 --- a/exit_db/migrations/2019-02-22-214628_rita-setup/down.sql +++ /dev/null @@ -1,2 +0,0 @@ --- This file should undo anything in `up.sql` -DROP TABLE clients; \ No newline at end of file diff --git a/exit_db/migrations/2019-02-22-214628_rita-setup/up.sql b/exit_db/migrations/2019-02-22-214628_rita-setup/up.sql deleted file mode 100644 index 5e2c70792..000000000 --- a/exit_db/migrations/2019-02-22-214628_rita-setup/up.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE clients -( - mesh_ip varchar(40) CONSTRAINT firstkey PRIMARY KEY, - wg_pubkey varchar(44) NOT NULL, - wg_port integer NOT NULL, - eth_address varchar(64) NOT NULL, - internal_ip varchar(42) NOT NULL, - nickname varchar(32) NOT NULL, - email varchar(512) NOT NULL, - phone varchar(32) NOT NULL, - country varchar(8) NOT NULL, - email_code varchar(16) NOT NULL, - verified boolean DEFAULT FALSE NOT NULL, - email_sent_time bigint DEFAULT 0 NOT NULL, - text_sent integer DEFAULT 0 NOT NULL, - last_seen bigint DEFAULT 0 NOT NULL, - last_balance_warning_time bigint DEFAULT 0 NOT NULL -); \ No newline at end of file diff --git a/exit_db/migrations/2022-05-18-184145_ipv6_migration/down.sql b/exit_db/migrations/2022-05-18-184145_ipv6_migration/down.sql deleted file mode 100644 index e42354d99..000000000 --- a/exit_db/migrations/2022-05-18-184145_ipv6_migration/down.sql +++ /dev/null @@ -1,5 +0,0 @@ --- This file should undo anything in `up.sql` -ALTER TABLE clients - DROP COLUMN internet_ipv6 -; -DROP TABLE assigned_ips; \ No newline at end of file diff --git a/exit_db/migrations/2022-05-18-184145_ipv6_migration/up.sql b/exit_db/migrations/2022-05-18-184145_ipv6_migration/up.sql deleted file mode 100644 index cd3982421..000000000 --- a/exit_db/migrations/2022-05-18-184145_ipv6_migration/up.sql +++ /dev/null @@ -1,10 +0,0 @@ --- Your SQL goes here -ALTER TABLE clients - ADD COLUMN internet_ipv6 varchar(132) NOT NULL DEFAULT '' -; -CREATE TABLE assigned_ips -( - subnet varchar(132) CONSTRAINT secondkey PRIMARY KEY, - available_subnets varchar(512) NOT NULL, - iterative_index bigint DEFAULT 0 NOT NULL -); \ No newline at end of file diff --git a/exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/down.sql b/exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/down.sql deleted file mode 100644 index c6d3c27da..000000000 --- a/exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/down.sql +++ /dev/null @@ -1,4 +0,0 @@ --- This file should undo anything in `up.sql` -ALTER TABLE assigned_ips - ALTER COLUMN available_subnets type varchar(512) -; diff --git a/exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/up.sql b/exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/up.sql deleted file mode 100644 index edbd08fe1..000000000 --- a/exit_db/migrations/2023-07-03-185432_ipv6_varchar_update/up.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Your SQL goes here -ALTER TABLE assigned_ips - ALTER COLUMN available_subnets type varchar -; \ No newline at end of file diff --git a/exit_db/src/lib.rs b/exit_db/src/lib.rs deleted file mode 100644 index 244963cc8..000000000 --- a/exit_db/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[macro_use] -extern crate diesel; -#[macro_use] -extern crate serde_derive; - -pub mod models; -pub mod schema; diff --git a/exit_db/src/models.rs b/exit_db/src/models.rs deleted file mode 100644 index cd9babc70..000000000 --- a/exit_db/src/models.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![allow(clippy::extra_unused_lifetimes)] -use crate::schema::assigned_ips; -use crate::schema::clients; - -#[derive(Queryable, Serialize, Deserialize, Debug, Insertable, Clone, Default)] -#[table_name = "clients"] -pub struct Client { - pub mesh_ip: String, - pub wg_pubkey: String, - pub wg_port: i32, - pub eth_address: String, - pub internal_ip: String, - pub internet_ipv6: String, - pub nickname: String, - pub email: String, - pub phone: String, - pub country: String, - pub email_code: String, - pub verified: bool, - pub email_sent_time: i64, - pub text_sent: i32, - pub last_seen: i64, - pub last_balance_warning_time: i64, -} - -/// This struct holds information about the ipv6 subnets being assigned to clients who connect. -/// The vector available subnets is a stack that has a list of available subnets to use. This stack gets populated whenever -/// a client gets removed from the database. It is stored as a string of indecies, for example, "1,24,36" -/// The iterative index stores the index at which we assign a subnet to a client -/// For example, if our exit subnet is fd00::1000/120 and our client subnets are /124, index 0 represents -/// fd00::1000/124 index 1 represents fd00::1010/124, 2 is fd00::1120/124 etc... -#[derive(Queryable, Serialize, Deserialize, Debug, Insertable, Clone, Default)] -#[table_name = "assigned_ips"] -pub struct AssignedIps { - pub subnet: String, - pub available_subnets: String, - pub iterative_index: i64, -} diff --git a/exit_db/src/schema.rs b/exit_db/src/schema.rs deleted file mode 100644 index d8470b758..000000000 --- a/exit_db/src/schema.rs +++ /dev/null @@ -1,28 +0,0 @@ -table! { - clients (mesh_ip) { - mesh_ip -> Varchar, - wg_pubkey -> Varchar, - wg_port -> Int4, - eth_address -> Varchar, - internal_ip -> Varchar, - internet_ipv6 -> Varchar, - nickname -> Varchar, - email -> Varchar, - phone -> Varchar, - country -> Varchar, - email_code -> Varchar, - verified -> Bool, - email_sent_time -> Int8, - text_sent -> Int4, - last_seen -> Int8, - last_balance_warning_time -> Int8, - } -} - -table! { - assigned_ips (subnet) { - subnet -> Varchar, - available_subnets -> Varchar, - iterative_index -> Int8, - } -} diff --git a/integration_tests/src/contract_test.rs b/integration_tests/src/contract_test.rs index 8f57d3c0c..ea87c45d5 100644 --- a/integration_tests/src/contract_test.rs +++ b/integration_tests/src/contract_test.rs @@ -1,6 +1,7 @@ use std::{thread, time::Duration}; use althea_types::Identity; +use log::info; use rita_client_registration::client_db::{ add_client_to_registered_list, get_all_regsitered_clients, get_registered_client_using_ethkey, get_registered_client_using_meship, get_registered_client_using_wgkey, @@ -9,10 +10,13 @@ use web30::client::Web3; use crate::{ payments_eth::{ETH_MINER_KEY, WEB3_TIMEOUT}, - utils::{get_altheadb_contract_addr, get_eth_node}, + utils::{deploy_contracts, get_altheadb_contract_addr, get_eth_node}, }; pub async fn run_altheadb_contract_test() { + info!("Waiting to deploy contracts"); + deploy_contracts().await; + // Try adding a dummy entry and validating that we can retrive them validate_contract_functionality().await; @@ -151,7 +155,7 @@ pub async fn validate_contract_functionality() { ) .await; - println!("All users are : {:?}", res); + info!("All users are : {:?}", res); thread::sleep(Duration::from_secs(5)); diff --git a/integration_tests/src/debts.rs b/integration_tests/src/debts.rs index 122e62927..0b123dcbf 100644 --- a/integration_tests/src/debts.rs +++ b/integration_tests/src/debts.rs @@ -3,18 +3,20 @@ use std::thread; use std::time::Duration; use crate::five_nodes::five_node_config; -use crate::setup_utils::database::start_postgres; +use crate::payments_eth::{ONE_ETH, WEB3_TIMEOUT}; +use crate::registration_server::start_registration_server; use crate::setup_utils::namespaces::*; use crate::setup_utils::rita::thread_spawner; use crate::utils::{ - generate_traffic, get_default_settings, get_ip_from_namespace, query_debts, - register_all_namespaces_to_exit, test_all_internet_connectivity, test_reach_all, test_routes, - DEBT_ACCURACY_THRES, TEST_EXIT_DETAILS, + deploy_contracts, generate_traffic, get_default_settings, get_ip_from_namespace, query_debts, + register_all_namespaces_to_exit, send_eth_bulk, test_all_internet_connectivity, test_reach_all, + test_routes, DEBT_ACCURACY_THRES, TEST_EXIT_DETAILS, }; use log::info; use num256::Int256; use num_traits::Signed; use rita_common::debt_keeper::GetDebtsResult; +use web30::client::Web3; type DebtsConfig = (Vec<(T, T)>, HashMap<(T, T), Vec>); @@ -44,6 +46,12 @@ pub async fn run_debts_test() { let namespaces = node_config.0; let expected_routes = node_config.1; + info!("Waiting to deploy contracts"); + deploy_contracts().await; + + info!("Starting registration server"); + start_registration_server(); + let (client_settings, exit_settings) = get_default_settings("test".to_string(), namespaces.clone()); @@ -51,12 +59,11 @@ pub async fn run_debts_test() { let exit_price = namespaces.get_namespace(4).unwrap().cost; namespaces.validate(); - start_postgres(); let res = setup_ns(namespaces.clone()); info!("Namespaces setup: {res:?}"); - let _rita_identities = thread_spawner(namespaces.clone(), client_settings, exit_settings) + let rita_identities = thread_spawner(namespaces.clone(), client_settings, exit_settings) .expect("Could not spawn Rita threads"); info!("Thread Spawner: {res:?}"); @@ -65,11 +72,25 @@ pub async fn run_debts_test() { test_routes(namespaces.clone(), expected_routes); + // Exits need to have funds to request a registered client list, which is needed for proper setup + info!("Topup exits with funds"); + let web3 = Web3::new("http://localhost:8545", WEB3_TIMEOUT); + let mut to_top_up = Vec::new(); + for c in rita_identities.client_identities { + to_top_up.push(c.eth_address); + } + for e in rita_identities.exit_identities { + to_top_up.push(e.eth_address) + } + + info!("Sending 50 eth to all routers"); + send_eth_bulk((ONE_ETH * 50).into(), &to_top_up, &web3).await; + info!("Registering routers to the exit"); register_all_namespaces_to_exit(namespaces.clone()).await; // Let network stabalize - thread::sleep(Duration::from_secs(20)); + thread::sleep(Duration::from_secs(10)); test_all_internet_connectivity(namespaces.clone()); diff --git a/integration_tests/src/five_nodes.rs b/integration_tests/src/five_nodes.rs index bcd3b1a63..3ca98ce71 100644 --- a/integration_tests/src/five_nodes.rs +++ b/integration_tests/src/five_nodes.rs @@ -1,9 +1,9 @@ use crate::payments_eth::{ONE_ETH, WEB3_TIMEOUT}; -use crate::setup_utils::database::start_postgres; +use crate::registration_server::start_registration_server; use crate::setup_utils::namespaces::*; use crate::setup_utils::rita::thread_spawner; use crate::utils::{ - get_default_settings, register_all_namespaces_to_exit, send_eth_bulk, + deploy_contracts, get_default_settings, register_all_namespaces_to_exit, send_eth_bulk, test_all_internet_connectivity, test_reach_all, test_routes, }; use log::info; @@ -20,12 +20,17 @@ pub async fn run_five_node_test_scenario() { let namespaces = node_config.0; let expected_routes = node_config.1; + info!("Waiting to deploy contracts"); + deploy_contracts().await; + + info!("Starting registration server"); + start_registration_server(); + let (client_settings, exit_settings) = get_default_settings("test".to_string(), namespaces.clone()); namespaces.validate(); - start_postgres(); let res = setup_ns(namespaces.clone()); info!("Namespaces setup: {res:?}"); @@ -61,6 +66,8 @@ pub async fn run_five_node_test_scenario() { info!("Checking for wg_exit tunnel setup"); test_all_internet_connectivity(namespaces.clone()); + + info!("All clients successfully registered!"); } /// This defines the network map for a five node scenario diff --git a/integration_tests/src/mutli_exit.rs b/integration_tests/src/mutli_exit.rs index bb5b40e9a..824bbcf74 100644 --- a/integration_tests/src/mutli_exit.rs +++ b/integration_tests/src/mutli_exit.rs @@ -1,18 +1,21 @@ use std::{collections::HashMap, str::from_utf8, thread, time::Duration}; use crate::{ + payments_eth::{ONE_ETH, WEB3_TIMEOUT}, + registration_server::start_registration_server, setup_utils::{ - database::start_postgres, namespaces::{setup_ns, Namespace, NamespaceInfo, NodeType, PriceId, RouteHop}, rita::thread_spawner, }, utils::{ - get_default_settings, get_node_id_from_ip, register_all_namespaces_to_exit, - test_all_internet_connectivity, test_reach_all, test_routes, + deploy_contracts, get_default_settings, get_node_id_from_ip, + register_all_namespaces_to_exit, send_eth_bulk, test_all_internet_connectivity, + test_reach_all, test_routes, }, }; use althea_kernel_interface::KI; use log::info; +use web30::client::Web3; /* Nodes are connected as such, 4 and 5 are exit: @@ -37,15 +40,20 @@ pub async fn run_multi_exit_test() { let namespaces = node_configs.0; let expected_routes = node_configs.1; + info!("Waiting to deploy contracts"); + deploy_contracts().await; + + info!("Starting registration server"); + start_registration_server(); + let (rita_client_settings, rita_exit_settings) = get_default_settings("test".to_string(), namespaces.clone()); namespaces.validate(); - start_postgres(); let res = setup_ns(namespaces.clone()); - let _rita_identities = + let rita_identities = thread_spawner(namespaces.clone(), rita_client_settings, rita_exit_settings) .expect("Could not spawn Rita threads"); info!("Thread Spawner: {res:?}"); @@ -55,13 +63,29 @@ pub async fn run_multi_exit_test() { test_routes(namespaces.clone(), expected_routes); + // Exits need to have funds to request a registered client list, which is needed for proper setup + info!("Topup exits with funds"); + let web3 = Web3::new("http://localhost:8545", WEB3_TIMEOUT); + let mut to_top_up = Vec::new(); + for c in rita_identities.client_identities { + to_top_up.push(c.eth_address); + } + for e in rita_identities.exit_identities { + to_top_up.push(e.eth_address) + } + + info!("Sending 50 eth to all routers"); + send_eth_bulk((ONE_ETH * 50).into(), &to_top_up, &web3).await; + info!("Registering routers to the exit"); register_all_namespaces_to_exit(namespaces.clone()).await; - thread::sleep(Duration::from_secs(5)); + thread::sleep(Duration::from_secs(10)); test_all_internet_connectivity(namespaces.clone()); + info!("All clients successfully registered!"); + let current_exit = get_current_exit(namespaces.names[0].clone(), namespaces.clone()); info!( "All nodes are set up correctly and are connected to exit {}", diff --git a/integration_tests/src/payments_althea.rs b/integration_tests/src/payments_althea.rs index 70b0dd9b9..2286436be 100644 --- a/integration_tests/src/payments_althea.rs +++ b/integration_tests/src/payments_althea.rs @@ -3,13 +3,15 @@ use std::thread; use std::time::Duration; use crate::five_nodes::five_node_config; -use crate::setup_utils::database::start_postgres; +use crate::payments_eth::{ONE_ETH, WEB3_TIMEOUT}; +use crate::registration_server::start_registration_server; use crate::setup_utils::namespaces::*; use crate::setup_utils::rita::thread_spawner; use crate::utils::{ - generate_traffic, get_default_settings, print_althea_balances, register_all_namespaces_to_exit, - register_erc20_usdc_token, send_althea_tokens, test_reach_all, test_routes, - validate_debt_entry, TEST_PAY_THRESH, + deploy_contracts, generate_traffic, get_default_settings, print_althea_balances, + register_all_namespaces_to_exit, register_erc20_usdc_token, send_althea_tokens, send_eth_bulk, + test_all_internet_connectivity, test_reach_all, test_routes, validate_debt_entry, + TEST_PAY_THRESH, }; use althea_types::{Denom, SystemChain, ALTHEA_PREFIX}; use deep_space::Address as AltheaAddress; @@ -18,6 +20,7 @@ use log::info; use rita_common::debt_keeper::GetDebtsResult; use settings::client::RitaClientSettings; use settings::exit::RitaExitSettingsStruct; +use web30::client::Web3; const USDC_TO_WEI_DECIMAL: u64 = 1_000_000_000_000u64; @@ -43,11 +46,16 @@ pub async fn run_althea_payments_test_scenario() { let namespaces = node_config.0; let expected_routes = node_config.1; + info!("Waiting to deploy contracts"); + deploy_contracts().await; + + info!("Starting registration server"); + start_registration_server(); + let (mut client_settings, mut exit_settings) = get_default_settings("test".to_string(), namespaces.clone()); namespaces.validate(); - start_postgres(); let res = setup_ns(namespaces.clone()); info!("Namespaces setup: {res:?}"); @@ -65,11 +73,28 @@ pub async fn run_althea_payments_test_scenario() { test_routes(namespaces.clone(), expected_routes); + // Exits need to have funds to request a registered client list, which is needed for proper setup + info!("Topup exits with funds"); + let web3 = Web3::new("http://localhost:8545", WEB3_TIMEOUT); + let mut to_top_up = Vec::new(); + for c in rita_identities.client_identities.clone() { + to_top_up.push(c.eth_address); + } + for e in rita_identities.exit_identities.clone() { + to_top_up.push(e.eth_address) + } + + info!("Sending 50 eth to all routers"); + send_eth_bulk((ONE_ETH * 50).into(), &to_top_up, &web3).await; + info!("Registering routers to the exit"); register_all_namespaces_to_exit(namespaces.clone()).await; thread::sleep(Duration::from_secs(10)); + test_all_internet_connectivity(namespaces.clone()); + info!("Successfully registered all clients"); + let from_node: Option = namespaces.get_namespace(1); let forward_node: Option = namespaces.get_namespace(3); let end_node: Option = namespaces.get_namespace(6); diff --git a/integration_tests/src/payments_eth.rs b/integration_tests/src/payments_eth.rs index dde886b2f..0fa74fb2f 100644 --- a/integration_tests/src/payments_eth.rs +++ b/integration_tests/src/payments_eth.rs @@ -1,8 +1,10 @@ use crate::five_nodes::five_node_config; -use crate::setup_utils::database::start_postgres; +use crate::registration_server::start_registration_server; use crate::setup_utils::namespaces::setup_ns; use crate::setup_utils::namespaces::Namespace; use crate::setup_utils::rita::thread_spawner; +use crate::utils::deploy_contracts; +use crate::utils::test_all_internet_connectivity; use crate::utils::{generate_traffic, register_all_namespaces_to_exit, validate_debt_entry}; use crate::utils::{ get_default_settings, send_eth_bulk, test_reach_all, test_routes, TEST_PAY_THRESH, @@ -44,6 +46,12 @@ pub async fn run_eth_payments_test_scenario() { let namespaces = node_config.0; let expected_routes = node_config.1; + info!("Waiting to deploy contracts"); + deploy_contracts().await; + + info!("Starting registration server"); + start_registration_server(); + let (mut client_settings, mut exit_settings) = get_default_settings("test".to_string(), namespaces.clone()); @@ -52,7 +60,6 @@ pub async fn run_eth_payments_test_scenario() { eth_payments_map(&mut client_settings, &mut exit_settings); namespaces.validate(); - start_postgres(); let res = setup_ns(namespaces.clone()); info!("Namespaces setup: {res:?}"); @@ -64,16 +71,8 @@ pub async fn run_eth_payments_test_scenario() { test_reach_all(namespaces.clone()); test_routes(namespaces.clone(), expected_routes); - info!("Registering routers to the exit"); - register_all_namespaces_to_exit(namespaces.clone()).await; - - thread::sleep(Duration::from_secs(10)); - - let from_node: Option = namespaces.get_namespace(1); - let forward_node: Option = namespaces.get_namespace(3); - let end_node: Option = namespaces.get_namespace(6); - - // start main test content + // Exits need to have funds to request a registered client list, which is needed for proper setup + info!("Topup exits with funds"); let web3 = Web3::new("http://localhost:8545", WEB3_TIMEOUT); let mut to_top_up = Vec::new(); for c in rita_identities.client_identities { @@ -86,6 +85,22 @@ pub async fn run_eth_payments_test_scenario() { info!("Sending 50 eth to all routers"); send_eth_bulk((ONE_ETH * 50).into(), &to_top_up, &web3).await; + info!("Registering routers to the exit"); + register_all_namespaces_to_exit(namespaces.clone()).await; + + thread::sleep(Duration::from_secs(10)); + + info!("Checking for wg_exit tunnel setup"); + test_all_internet_connectivity(namespaces.clone()); + + info!("All clients successfully registered!"); + + thread::sleep(Duration::from_secs(10)); + + let from_node: Option = namespaces.get_namespace(1); + let forward_node: Option = namespaces.get_namespace(3); + let end_node: Option = namespaces.get_namespace(6); + info!("Trying to generate traffic"); generate_traffic( from_node.clone().unwrap(), diff --git a/rita_client/src/exit_manager/mod.rs b/rita_client/src/exit_manager/mod.rs index e584b5831..0817fefcb 100644 --- a/rita_client/src/exit_manager/mod.rs +++ b/rita_client/src/exit_manager/mod.rs @@ -363,7 +363,6 @@ async fn send_exit_setup_request( ident: ExitClientIdentity, ) -> Result { let endpoint = format!("http://[{}]:{}/secure_setup", to.ip(), to.port()); - error!("Trying to hit endpoint: {:?}", endpoint); let ident = encrypt_exit_client_id(&exit_pubkey.into(), ident); diff --git a/rita_client_registration/src/lib.rs b/rita_client_registration/src/lib.rs index d80af01cd..53e45f676 100644 --- a/rita_client_registration/src/lib.rs +++ b/rita_client_registration/src/lib.rs @@ -158,13 +158,7 @@ async fn client_exists( .await; match c_id { Ok(a) => client.global == a, - Err(e) => { - warn!( - "Error retrieving an identity with wg key {} with {}", - client.global.wg_public_key, e - ); - false - } + Err(_) => false, } } @@ -178,10 +172,6 @@ pub async fn handle_sms_registration( "Handling phone registration for {}", client.global.wg_public_key ); - error!( - "Handling phone registration for {}", - client.global.wg_public_key - ); // Get magic phone number let magic_phone_number = magic_number; @@ -390,7 +380,6 @@ pub fn register_client_batch_loop( let mut batch = vec![]; for id in reg_clients { - error!("This batch has {}", id.mesh_ip); match contact .send_transaction( contract_addr, diff --git a/rita_exit/src/rita_loop/mod.rs b/rita_exit/src/rita_loop/mod.rs index 5ee1a9284..9912ddba2 100644 --- a/rita_exit/src/rita_loop/mod.rs +++ b/rita_exit/src/rita_loop/mod.rs @@ -157,8 +157,6 @@ async fn rita_exit_loop(rita_exit_cache: RitaExitCache, usage_history: ExitLock) }; } - error!("received reg clients: {:?}", reg_clients_list); - info!( "Finished Rita get clients, got {:?} clients in {}ms", reg_clients_list.len(), diff --git a/settings/example_exit.toml b/settings/example_exit.toml index ae636e0cd..3615e4ece 100644 --- a/settings/example_exit.toml +++ b/settings/example_exit.toml @@ -44,6 +44,7 @@ subnet = "fd00::1337/40" entry_timeout = 7776000 wg_public_key = "H/ABwzXk834OwGYU8CZGfFxNZOd+BAJEaVDHiEiWWhU=" wg_private_key = "ALxcZm2r58gY0sB4vIfnjShc86qBoVK3f32H9VrwqWU=" +registered_users_contract_addr = "0x5AeE3Dff733F56cFe7E5390B9cC3A46a90cA1CfA" wg_private_key_path = "/tmp/exit-priv" pass = "Some pass here" diff --git a/settings/test_exit.toml b/settings/test_exit.toml index 476684050..761b9d678 100644 --- a/settings/test_exit.toml +++ b/settings/test_exit.toml @@ -41,6 +41,7 @@ entry_timeout = 7776000 wg_public_key = "H/ABwzXk834OwGYU8CZGfFxNZOd+BAJEaVDHiEiWWhU=" wg_private_key = "ALxcZm2r58gY0sB4vIfnjShc86qBoVK3f32H9VrwqWU=" wg_private_key_path = "/tmp/exit-priv" +registered_users_contract_addr = "0x5AeE3Dff733F56cFe7E5390B9cC3A46a90cA1CfA" pass = "Some pass here" [[exit_network.cluster_exits]] diff --git a/test_runner/src/main.rs b/test_runner/src/main.rs index e52ba9606..127a6277f 100644 --- a/test_runner/src/main.rs +++ b/test_runner/src/main.rs @@ -6,8 +6,6 @@ use integration_tests::debts::run_debts_test; /// Binary crate for actually running the integration tests use integration_tests::five_nodes::run_five_node_test_scenario; use integration_tests::mutli_exit::run_multi_exit_test; -use integration_tests::registration_server::start_registration_server; -use integration_tests::utils::deploy_contracts; use integration_tests::{ payments_althea::run_althea_payments_test_scenario, payments_eth::run_eth_payments_test_scenario, utils::set_sigterm, @@ -42,12 +40,6 @@ async fn main() { let conf = generate_exit_config_file(EXIT_CONFIG_PATH.to_string()); info!("Generating exit config file: {:?}", conf); - println!("Waiting to deploy contracts"); - deploy_contracts().await; - - println!("Starting registration server"); - start_registration_server(); - let test_type = env::var("TEST_TYPE"); info!("Starting tests with {:?}", test_type); if let Ok(test_type) = test_type {