Skip to content

Commit

Permalink
Change miner key name
Browse files Browse the repository at this point in the history
There shouldn't be two keys both called 'the miner key'
  • Loading branch information
jkilpatr committed Nov 29, 2023
1 parent 4728a66 commit d0bf08a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions integration_tests/src/contract_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use web30::{client::Web3, types::SendTxOption};

use crate::{
payments_eth::WEB3_TIMEOUT,
utils::{deploy_contracts, get_eth_node, wait_for_txids, MINER_PRIVATE_KEY, TX_TIMEOUT},
utils::{deploy_contracts, get_eth_node, wait_for_txids, REGISTRATION_SERVER_KEY, TX_TIMEOUT},
};

pub async fn run_altheadb_contract_test() {
Expand All @@ -27,7 +27,7 @@ pub async fn run_altheadb_contract_test() {
}

pub async fn validate_contract_exit_functionality(db_addr: Address) {
let miner_private_key: PrivateKey = MINER_PRIVATE_KEY.parse().unwrap();
let miner_private_key: PrivateKey = REGISTRATION_SERVER_KEY.parse().unwrap();
let miner_pub_key = miner_private_key.to_address();

let contact = Web3::new(&get_eth_node(), WEB3_TIMEOUT);
Expand Down Expand Up @@ -163,7 +163,7 @@ pub async fn validate_contract_exit_functionality(db_addr: Address) {
}

pub async fn validate_contract_user_functionality(db_addr: Address) {
let miner_private_key: PrivateKey = MINER_PRIVATE_KEY.parse().unwrap();
let miner_private_key: PrivateKey = REGISTRATION_SERVER_KEY.parse().unwrap();
let miner_pub_key = miner_private_key.to_address();

let contact = Web3::new(&get_eth_node(), WEB3_TIMEOUT);
Expand Down
22 changes: 11 additions & 11 deletions integration_tests/src/db_migration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use rita_db_migration::{
use web30::client::Web3;

use crate::{
payments_eth::{get_eth_miner_key, WEB3_TIMEOUT},
payments_eth::{TRASACTION_TIMEOUT, WEB3_TIMEOUT},
setup_utils::database::start_postgres,
utils::{deploy_contracts, get_eth_node, MINER_PRIVATE_KEY},
utils::{deploy_contracts, get_eth_node, REGISTRATION_SERVER_KEY},
};

pub const DB_URI: &str = "postgres://postgres@localhost/test";
Expand All @@ -45,16 +45,16 @@ pub async fn run_db_migration_test() {

info!("Run migration code");

let miner_private_key: PrivateKey = get_eth_miner_key();
let reg_server_key: PrivateKey = REGISTRATION_SERVER_KEY.parse().unwrap();
// Start registration loop
info!("Registering user admin");
// This request needs to be made with the state admin's key
check_and_add_user_admin(
&Web3::new(&get_eth_node(), WEB3_TIMEOUT),
althea_db_addr,
MINER_PRIVATE_KEY.parse().unwrap(),
miner_private_key,
Some(WEB3_TIMEOUT),
reg_server_key.to_address(),
reg_server_key,
Some(TRASACTION_TIMEOUT),
vec![],
)
.await
Expand All @@ -63,13 +63,13 @@ pub async fn run_db_migration_test() {
thread::sleep(Duration::from_secs(5));

info!("Starting registration loop");
register_client_batch_loop(get_eth_node(), althea_db_addr, miner_private_key);
register_client_batch_loop(get_eth_node(), althea_db_addr, reg_server_key);

info!("Running user migration");
match start_db_migration(
DB_URI.to_string(),
get_eth_node(),
miner_private_key.to_address(),
reg_server_key.to_address(),
althea_db_addr,
)
.await
Expand All @@ -81,7 +81,7 @@ pub async fn run_db_migration_test() {
info!("Waiting for register loop to migrate all clients");
thread::sleep(Duration::from_secs(10));

validate_db_migration(num_clients, althea_db_addr, miner_private_key).await;
validate_db_migration(num_clients, althea_db_addr, reg_server_key).await;
}

fn add_dummy_clients_to_db(num_of_entries: usize, conn: &PgConnection) {
Expand Down Expand Up @@ -122,9 +122,9 @@ fn random_db_client() -> Client {
async fn validate_db_migration(
num_clients: usize,
althea_db_addr: Address,
miner_private_key: PrivateKey,
reg_server_key: PrivateKey,
) {
let miner_pub_key = miner_private_key.to_address();
let miner_pub_key = reg_server_key.to_address();
let contact = Web3::new(&get_eth_node(), WEB3_TIMEOUT);

let start = Instant::now();
Expand Down
1 change: 1 addition & 0 deletions integration_tests/src/payments_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn eth_chain_id() -> Uint256 {
}

pub const WEB3_TIMEOUT: Duration = Duration::from_secs(1);
pub const TRASACTION_TIMEOUT: Duration = Duration::from_secs(30);
pub const ONE_ETH: u128 = 1_000_000_000_000_000_000;

/// Runs a five node fixed network map test scenario
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/registration_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ use crate::{
};
use crate::{
registration_server::register_client_batch_loop::register_client_batch_loop,
utils::MINER_PRIVATE_KEY,
utils::REGISTRATION_SERVER_KEY,
};

pub const REGISTRATION_PORT_SERVER: u16 = 40400;

pub async fn start_registration_server(db_addr: Address) {
let miner_private_key: PrivateKey = MINER_PRIVATE_KEY.parse().unwrap();
let miner_private_key: PrivateKey = REGISTRATION_SERVER_KEY.parse().unwrap();
let miner_pub_key = miner_private_key.to_address();
let contact = Web3::new(&get_eth_node(), WEB3_TIMEOUT);

Expand Down
6 changes: 3 additions & 3 deletions integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub const MIN_GLOBAL_FEE_AMOUNT: u128 = 10;
pub const TOTAL_TIMEOUT: Duration = Duration::from_secs(300);
pub const DEBT_ACCURACY_THRES: u8 = 15;
pub const ETH_NODE: &str = "http://localhost:8545";
pub const MINER_PRIVATE_KEY: &str =
pub const REGISTRATION_SERVER_KEY: &str =
"0x34d97aaf58b1a81d3ed3068a870d8093c6341cf5d1ef7e6efa03fe7f7fc2c3a8";

lazy_static! {
Expand Down Expand Up @@ -170,7 +170,7 @@ pub async fn deploy_contracts() -> Address {
.args([
"ts-node",
"/althea_rs/solidity/contract-deployer.ts",
&format!("--eth-privkey={}", MINER_PRIVATE_KEY),
&format!("--eth-privkey={}", REGISTRATION_SERVER_KEY),
&format!("--eth-node={}", ETH_NODE),
])
.output()
Expand Down Expand Up @@ -1106,7 +1106,7 @@ pub async fn populate_routers_eth(rita_identities: InstanceData) {

pub async fn add_exits_contract_exit_list(db_addr: Address, rita_identities: InstanceData) {
let web3 = Web3::new("http://localhost:8545", WEB3_TIMEOUT);
let miner_private_key: clarity::PrivateKey = MINER_PRIVATE_KEY.parse().unwrap();
let miner_private_key: clarity::PrivateKey = REGISTRATION_SERVER_KEY.parse().unwrap();
let miner_pub_key = miner_private_key.to_address();

add_exit_admin(
Expand Down

0 comments on commit d0bf08a

Please sign in to comment.