Skip to content

Commit

Permalink
refactor(service): make the add node naming more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin authored and joshuef committed Mar 11, 2024
1 parent 2b82061 commit 48429a5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion sn_node_manager/src/add_services/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl InstallNodeServiceCtxBuilder {
}
}

pub struct AddServiceOptions {
pub struct AddNodeServiceOptions {
pub bootstrap_peers: Vec<Multiaddr>,
pub count: Option<u16>,
pub env_variables: Option<Vec<(String, String)>>,
Expand Down
6 changes: 3 additions & 3 deletions sn_node_manager/src/add_services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod config;
mod tests;

use self::config::{
AddDaemonServiceOptions, AddFaucetServiceOptions, AddServiceOptions,
AddDaemonServiceOptions, AddFaucetServiceOptions, AddNodeServiceOptions,
InstallFaucetServiceCtxBuilder, InstallNodeServiceCtxBuilder,
};
use crate::{config::create_owned_dir, VerbosityLevel, DAEMON_SERVICE_NAME};
Expand All @@ -32,8 +32,8 @@ use std::{
///
/// There are several arguments that probably seem like they could be handled within the function,
/// but they enable more controlled unit testing.
pub async fn add(
options: AddServiceOptions,
pub async fn add_node(
options: AddNodeServiceOptions,
node_registry: &mut NodeRegistry,
service_control: &dyn ServiceControl,
verbosity: VerbosityLevel,
Expand Down
40 changes: 20 additions & 20 deletions sn_node_manager/src/add_services/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

use crate::{
add_services::{
add, add_daemon, add_faucet,
add_daemon, add_faucet, add_node,
config::{
AddDaemonServiceOptions, AddFaucetServiceOptions, AddServiceOptions,
AddDaemonServiceOptions, AddFaucetServiceOptions, AddNodeServiceOptions,
InstallNodeServiceCtxBuilder,
},
},
Expand Down Expand Up @@ -128,8 +128,8 @@ async fn add_genesis_node_should_use_latest_version_and_add_one_service() -> Res
.returning(|_| Ok(()))
.in_sequence(&mut seq);

add(
AddServiceOptions {
add_node(
AddNodeServiceOptions {
local: true,
genesis: true,
count: None,
Expand Down Expand Up @@ -223,8 +223,8 @@ async fn add_genesis_node_should_return_an_error_if_there_is_already_a_genesis_n

let custom_rpc_address = Ipv4Addr::new(127, 0, 0, 1);

let result = add(
AddServiceOptions {
let result = add_node(
AddNodeServiceOptions {
local: true,
genesis: true,
count: None,
Expand Down Expand Up @@ -281,8 +281,8 @@ async fn add_genesis_node_should_return_an_error_if_count_is_greater_than_1() ->

let custom_rpc_address = Ipv4Addr::new(127, 0, 0, 1);

let result = add(
AddServiceOptions {
let result = add_node(
AddNodeServiceOptions {
local: true,
genesis: true,
count: Some(3),
Expand Down Expand Up @@ -433,8 +433,8 @@ async fn add_node_should_use_latest_version_and_add_three_services() -> Result<(
.returning(|_| Ok(()))
.in_sequence(&mut seq);

add(
AddServiceOptions {
add_node(
AddNodeServiceOptions {
local: false,
genesis: false,
count: Some(3),
Expand Down Expand Up @@ -571,8 +571,8 @@ async fn add_node_should_update_the_bootstrap_peers_inside_node_registry() -> Re
.returning(|_| Ok(()))
.in_sequence(&mut seq);

add(
AddServiceOptions {
add_node(
AddNodeServiceOptions {
local: false,
genesis: false,
count: None,
Expand Down Expand Up @@ -683,8 +683,8 @@ async fn add_node_should_update_the_environment_variables_inside_node_registry()
.returning(|_| Ok(()))
.in_sequence(&mut seq);

add(
AddServiceOptions {
add_node(
AddNodeServiceOptions {
local: false,
genesis: false,
count: None,
Expand Down Expand Up @@ -805,8 +805,8 @@ async fn add_new_node_should_add_another_service() -> Result<()> {
.returning(|_| Ok(()))
.in_sequence(&mut seq);

add(
AddServiceOptions {
add_node(
AddNodeServiceOptions {
local: false,
genesis: false,
count: None,
Expand Down Expand Up @@ -908,8 +908,8 @@ async fn add_node_should_use_custom_ports_for_one_service() -> Result<()> {
.returning(|_| Ok(()))
.in_sequence(&mut seq);

add(
AddServiceOptions {
add_node(
AddNodeServiceOptions {
local: false,
genesis: false,
count: None,
Expand Down Expand Up @@ -980,8 +980,8 @@ async fn add_node_should_return_error_if_custom_port_is_used_and_more_than_one_s

let custom_port = 12000;

let result = add(
AddServiceOptions {
let result = add_node(
AddNodeServiceOptions {
local: true,
genesis: false,
count: Some(3),
Expand Down
8 changes: 4 additions & 4 deletions sn_node_manager/src/bin/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use libp2p_identity::PeerId;
use semver::Version;
use sn_node_manager::{
add_services::{
add, add_daemon, add_faucet,
config::{AddDaemonServiceOptions, AddFaucetServiceOptions, AddServiceOptions},
add_daemon, add_faucet, add_node,
config::{AddDaemonServiceOptions, AddFaucetServiceOptions, AddNodeServiceOptions},
},
config::*,
helpers::{download_and_extract_release, get_bin_version},
Expand Down Expand Up @@ -476,7 +476,7 @@ async fn main() -> Result<()> {
&*release_repo,
)
.await?;
let options = AddServiceOptions {
let options = AddNodeServiceOptions {
local,
genesis: peers.first,
count,
Expand All @@ -493,7 +493,7 @@ async fn main() -> Result<()> {
env_variables,
};

add(options, &mut node_registry, &service_manager, verbosity).await?;
add_node(options, &mut node_registry, &service_manager, verbosity).await?;

node_registry.save()?;

Expand Down

0 comments on commit 48429a5

Please sign in to comment.