mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 04:48:21 +00:00
Add tests for validator create
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use super::common::*;
|
||||
use crate::DumpConfigs;
|
||||
use crate::DumpConfig;
|
||||
use account_utils::{random_password_string, read_mnemonic_from_cli, read_password_from_user};
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use eth2::{
|
||||
@@ -51,7 +51,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
"The path to a directory where the validator and (optionally) deposits \
|
||||
files will be created. The directory will be created if it does not exist.",
|
||||
)
|
||||
.conflicts_with(DISABLE_DEPOSITS_FLAG)
|
||||
.required(true)
|
||||
.takes_value(true),
|
||||
)
|
||||
@@ -100,7 +99,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name(DISABLE_DEPOSITS_FLAG)
|
||||
.long(DISABLE_DEPOSITS_FLAG)
|
||||
.value_name("PATH")
|
||||
.help(
|
||||
"When provided don't generate the deposits JSON file that is \
|
||||
commonly used for submitting validator deposits via a web UI. \
|
||||
@@ -111,8 +109,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name(SPECIFY_VOTING_KEYSTORE_PASSWORD_FLAG)
|
||||
.long(SPECIFY_VOTING_KEYSTORE_PASSWORD_FLAG)
|
||||
.value_name("STRING")
|
||||
.takes_value(true)
|
||||
.help(
|
||||
"If present, the user will be prompted to enter the voting keystore \
|
||||
password that will be used to encrypt the voting keystores. If this \
|
||||
@@ -181,7 +177,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
|
||||
/// The CLI arguments are parsed into this struct before running the application. This step of
|
||||
/// indirection allows for testing the underlying logic without needing to parse CLI arguments.
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub struct CreateConfig {
|
||||
pub output_path: PathBuf,
|
||||
pub first_index: u32,
|
||||
@@ -461,10 +457,10 @@ impl ValidatorsAndDeposits {
|
||||
pub async fn cli_run<'a, T: EthSpec>(
|
||||
matches: &'a ArgMatches<'a>,
|
||||
spec: &ChainSpec,
|
||||
dump_configs: DumpConfigs,
|
||||
dump_config: DumpConfig,
|
||||
) -> Result<(), String> {
|
||||
let config = CreateConfig::from_cli(matches, spec)?;
|
||||
if dump_configs.should_exit_early(&config)? {
|
||||
if dump_config.should_exit_early(&config)? {
|
||||
Ok(())
|
||||
} else {
|
||||
run::<T>(config, spec).await
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::common::*;
|
||||
use crate::DumpConfigs;
|
||||
use crate::DumpConfig;
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
use eth2::{
|
||||
lighthouse_vc::{
|
||||
@@ -95,10 +95,10 @@ impl ImportConfig {
|
||||
|
||||
pub async fn cli_run<'a>(
|
||||
matches: &'a ArgMatches<'a>,
|
||||
dump_configs: DumpConfigs,
|
||||
dump_config: DumpConfig,
|
||||
) -> Result<(), String> {
|
||||
let config = ImportConfig::from_cli(matches)?;
|
||||
if dump_configs.should_exit_early(&config)? {
|
||||
if dump_config.should_exit_early(&config)? {
|
||||
Ok(())
|
||||
} else {
|
||||
run(config).await
|
||||
|
||||
@@ -2,7 +2,7 @@ pub mod common;
|
||||
pub mod create_validators;
|
||||
pub mod import_validators;
|
||||
|
||||
use crate::DumpConfigs;
|
||||
use crate::DumpConfig;
|
||||
use clap::{App, ArgMatches};
|
||||
use types::{ChainSpec, EthSpec};
|
||||
|
||||
@@ -18,14 +18,14 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
pub async fn cli_run<'a, T: EthSpec>(
|
||||
matches: &'a ArgMatches<'a>,
|
||||
spec: &ChainSpec,
|
||||
dump_configs: DumpConfigs,
|
||||
dump_config: DumpConfig,
|
||||
) -> Result<(), String> {
|
||||
match matches.subcommand() {
|
||||
(create_validators::CMD, Some(matches)) => {
|
||||
create_validators::cli_run::<T>(matches, spec, dump_configs).await
|
||||
create_validators::cli_run::<T>(matches, spec, dump_config).await
|
||||
}
|
||||
(import_validators::CMD, Some(matches)) => {
|
||||
import_validators::cli_run(matches, dump_configs).await
|
||||
import_validators::cli_run(matches, dump_config).await
|
||||
}
|
||||
(unknown, _) => Err(format!(
|
||||
"{} does not have a {} command. See --help",
|
||||
|
||||
Reference in New Issue
Block a user