Skip to content

Commit

Permalink
Fix CI wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranay Tulugu committed Oct 10, 2023
1 parent 7f09a0d commit ccf4056
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 39 deletions.
2 changes: 1 addition & 1 deletion integration_tests/src/debts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub async fn run_debts_test() {
let db_addr = deploy_contracts().await;

info!("Starting registration server");
start_registration_server(db_addr);
start_registration_server(db_addr).await;

let (client_settings, exit_settings) =
get_default_settings("test".to_string(), namespaces.clone());
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/src/five_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub async fn run_five_node_test_scenario() {
info!("Registering routers to the exit");
register_all_namespaces_to_exit(namespaces.clone()).await;

thread::sleep(Duration::from_secs(10));
thread::sleep(Duration::from_secs(1000));

info!("Checking for wg_exit tunnel setup");
test_all_internet_connectivity(namespaces.clone());
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/src/mutli_exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn run_multi_exit_test() {
let db_addr = deploy_contracts().await;

info!("Starting registration server");
start_registration_server(db_addr);
start_registration_server(db_addr).await;

let (rita_client_settings, rita_exit_settings) =
get_default_settings("test".to_string(), namespaces.clone());
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/src/payments_althea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub async fn run_althea_payments_test_scenario() {
let db_addr = deploy_contracts().await;

info!("Starting registration server");
start_registration_server(db_addr);
start_registration_server(db_addr).await;

let (mut client_settings, mut exit_settings) =
get_default_settings("test".to_string(), namespaces.clone());
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/src/payments_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn run_eth_payments_test_scenario() {
let db_addr = deploy_contracts().await;

info!("Starting registration server");
start_registration_server(db_addr);
start_registration_server(db_addr).await;

let (mut client_settings, mut exit_settings) =
get_default_settings("test".to_string(), namespaces.clone());
Expand Down
32 changes: 3 additions & 29 deletions integration_tests/src/registration_server.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use std::{
sync::{Arc, RwLock},
thread,
time::Duration,
};
use std::{thread, time::Duration};

use actix_rt::System;
use actix_web::{
Expand All @@ -17,35 +13,17 @@ use rita_client_registration::{
use web30::client::Web3;

use crate::{
payments_eth::{get_miner_address, get_miner_key, WEB3_TIMEOUT},
payments_eth::WEB3_TIMEOUT,
utils::{get_eth_node, get_test_runner_magic_phone},
};
use crate::{
registration_server::register_client_batch_loop::register_client_batch_loop,
utils::MINER_PRIVATE_KEY,
};
use log::{error, info};
use log::info;

pub const REGISTRATION_PORT_SERVER: u16 = 40400;

#[derive(Clone, Copy, Debug, Default)]
struct RegistrationServerState {
pub db_contract_addr: Option<Address>,
}

lazy_static! {
static ref REGISTRATION_SERVER_STATE: Arc<RwLock<RegistrationServerState>> =
Arc::new(RwLock::new(RegistrationServerState::default()));
}

fn get_althea_db_addr() -> Option<Address> {
REGISTRATION_SERVER_STATE.read().unwrap().db_contract_addr
}

fn set_althea_db_addr(addr: Address) {
REGISTRATION_SERVER_STATE.write().unwrap().db_contract_addr = Some(addr)
}

pub async fn start_registration_server(db_addr: Address) {
let miner_private_key: PrivateKey = MINER_PRIVATE_KEY.parse().unwrap();
let miner_pub_key = miner_private_key.to_address();
Expand All @@ -67,7 +45,6 @@ pub async fn start_registration_server(db_addr: Address) {
// Start the register loop
register_client_batch_loop(get_eth_node(), db_addr, miner_private_key);

set_althea_db_addr(db_addr);
// Start endpoint listener
thread::spawn(move || {
let runner = System::new();
Expand All @@ -91,9 +68,6 @@ async fn register_router(client: Json<ExitClientIdentity>) -> HttpResponse {
let client = client.into_inner();
info!("Attempting to register client: {}", client.global.mesh_ip);

// Check for an existing client
let client = client;

HttpResponse::Ok().json(
handle_sms_registration(
client,
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ pub async fn add_exits_contract_exit_list(db_addr: Address, rita_identities: Ins
let miner_private_key: clarity::PrivateKey = MINER_PRIVATE_KEY.parse().unwrap();
let miner_pub_key = miner_private_key.to_address();

let _res = add_exit_admin(
let res = add_exit_admin(
&web3,
db_addr,
miner_pub_key,
Expand All @@ -1109,7 +1109,7 @@ pub async fn add_exits_contract_exit_list(db_addr: Address, rita_identities: Ins
.await
.unwrap();

thread::sleep(Duration::from_secs(5));
wait_for_txids(vec![Ok(res)], &web3).await;

let cluster = TEST_EXIT_DETAILS.get("test").unwrap();

Expand Down
2 changes: 2 additions & 0 deletions rita_client_registration/src/client_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub async fn get_all_regsitered_clients(
)
.await?;

error!("All reg users are : {:?}", bytes_to_hex_str(&res));

parse_identity_array_abi(res)
}

Expand Down
7 changes: 4 additions & 3 deletions rita_client_registration/src/register_client_batch_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ pub fn register_client_batch_loop(
}
}

let mut batch = vec![];
let mut batch: Vec<Uint256> = vec![];
error!("Reg clients are: {:?}", reg_clients);
for id in reg_clients {
if let IpAddr::V6(mesh_ip_v6) = id.mesh_ip {
match contact
Expand Down Expand Up @@ -109,7 +110,7 @@ pub fn register_client_batch_loop(
//increment nonce for next tx
nonce += 1u64.into();
remove_client_from_reg_batch(id);
error!("BATCH CLIENT: {}", id.mesh_ip);
error!("BATCH CLIENT: {} with txid {}", id.mesh_ip, tx_id);
batch.push(tx_id);
}
Err(e) => {
Expand All @@ -127,7 +128,7 @@ pub fn register_client_batch_loop(
// Join on txs
let res = wait_for_txids(batch, &contact).await;
for e in res {
error!("Tx is ok: {:?}", e.is_ok());
error!("Tx is: {:?}", e);
}

info!("Registration loop elapsed in = {:?}", start.elapsed());
Expand Down

0 comments on commit ccf4056

Please sign in to comment.