Skip to content

Commit

Permalink
fixed local testnet manager
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuczyn committed Dec 5, 2024
1 parent d4e0a08 commit a3386b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 40 deletions.
47 changes: 11 additions & 36 deletions tools/internal/testnet-manager/src/manager/local_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::manager::network::LoadedNetwork;
use crate::manager::node::NymNode;
use crate::manager::NetworkManager;
use console::style;
use nym_crypto::asymmetric::ed25519;
use nym_mixnet_contract_common::nym_node::Role;
use nym_mixnet_contract_common::RoleAssignment;
use nym_validator_client::nyxd::contract_traits::MixnetSigningClient;
Expand Down Expand Up @@ -89,28 +90,10 @@ impl<'a> LocalNodesCtx<'a> {
}
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "node_type")]
pub enum BondingInformationV1 {
Mixnode(MixnodeBondingInformation),
Gateway(GatewayBondingInformation),
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MixnodeBondingInformation {
pub(crate) version: String,
pub(crate) host: String,
pub(crate) identity_key: String,
pub(crate) sphinx_key: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct GatewayBondingInformation {
pub(crate) version: String,
pub(crate) host: String,
pub(crate) location: String,
pub(crate) identity_key: String,
pub(crate) sphinx_key: String,
#[derive(Debug, Deserialize, Serialize)]
pub struct BondingInformation {
host: String,
identity_key: ed25519::PublicKey,
}

#[derive(Deserialize)]
Expand Down Expand Up @@ -181,6 +164,9 @@ impl NetworkManager {

if is_gateway {
cmd.args(["--mode", "entry"]);
} else {
// be explicit about it, even though we don't have to be
cmd.args(["--mode", "mixnode"]);
}

let mut child = cmd.spawn()?;
Expand All @@ -191,20 +177,9 @@ impl NetworkManager {
}

let output_file = fs::File::open(&output_file_path)?;
let bonding_info: BondingInformationV1 = serde_json::from_reader(&output_file)?;

match bonding_info {
BondingInformationV1::Mixnode(bonding_info) => {
node.identity_key = bonding_info.identity_key;
node.sphinx_key = bonding_info.sphinx_key;
node.version = bonding_info.version;
}
BondingInformationV1::Gateway(bonding_info) => {
node.identity_key = bonding_info.identity_key;
node.sphinx_key = bonding_info.sphinx_key;
node.version = bonding_info.version;
}
}
let bonding_info: BondingInformation = serde_json::from_reader(&output_file)?;

node.identity_key = bonding_info.identity_key.to_string();

ctx.set_pb_message(format!("generating bonding signature for node {id}..."));

Expand Down
4 changes: 0 additions & 4 deletions tools/internal/testnet-manager/src/manager/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ pub(crate) struct NymNode {
pub(crate) verloc_port: u16,
pub(crate) http_port: u16,
pub(crate) clients_port: u16,
pub(crate) sphinx_key: String,
pub(crate) identity_key: String,
pub(crate) version: String,

pub(crate) owner: Account,
pub(crate) bonding_signature: String,
Expand All @@ -29,9 +27,7 @@ impl NymNode {
verloc_port: 0,
http_port: 0,
clients_port: 0,
sphinx_key: "".to_string(),
identity_key: "".to_string(),
version: "".to_string(),
owner: Account::new(),
bonding_signature: "".to_string(),
}
Expand Down

0 comments on commit a3386b4

Please sign in to comment.