From 89b832ccb1fc290a4c356eb0290ebac347b966f3 Mon Sep 17 00:00:00 2001 From: pawan Date: Thu, 3 Sep 2020 00:30:53 +0530 Subject: [PATCH] Fix tests --- account_manager/src/validator/mod.rs | 4 +++- account_manager/src/wallet/mod.rs | 3 ++- lighthouse/tests/account_manager.rs | 22 ++++++++-------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/account_manager/src/validator/mod.rs b/account_manager/src/validator/mod.rs index 83360fc472d..ef702222649 100644 --- a/account_manager/src/validator/mod.rs +++ b/account_manager/src/validator/mod.rs @@ -23,7 +23,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { "The path to search for validator directories. \ Defaults to ~/.lighthouse/{testnet}/validators", ) - .takes_value(true), + .takes_value(true) + .global(true) + .conflicts_with("datadir"), ) .about("Lists the names of all validators.") .subcommand(create::cli_app()) diff --git a/account_manager/src/wallet/mod.rs b/account_manager/src/wallet/mod.rs index b85e7d29de8..9195c9e4469 100644 --- a/account_manager/src/wallet/mod.rs +++ b/account_manager/src/wallet/mod.rs @@ -14,9 +14,10 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .arg( Arg::with_name(WALLETS_DIR_FLAG) .long(WALLETS_DIR_FLAG) - .value_name("BASE_DIRECTORY") + .value_name("WALLETS_DIRECTORY") .help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{testnet}/wallets") .takes_value(true) + .global(true) .conflicts_with("datadir"), ) .subcommand(create::cli_app()) diff --git a/lighthouse/tests/account_manager.rs b/lighthouse/tests/account_manager.rs index 28c9431707e..563186792c7 100644 --- a/lighthouse/tests/account_manager.rs +++ b/lighthouse/tests/account_manager.rs @@ -233,15 +233,15 @@ impl TestValidator { store_withdrawal_key: bool, ) -> Result, String> { let mut cmd = validator_cmd(); - cmd.arg(format!("--{}", WALLETS_DIR_FLAG)) - .arg(self.wallet.base_dir().into_os_string()) + cmd.arg(format!("--{}", VALIDATOR_DIR_FLAG)) + .arg(self.validator_dir.clone().into_os_string()) .arg(CREATE_CMD) + .arg(format!("--{}", WALLETS_DIR_FLAG)) + .arg(self.wallet.base_dir().into_os_string()) .arg(format!("--{}", WALLET_NAME_FLAG)) .arg(&self.wallet.name) .arg(format!("--{}", WALLET_PASSWORD_FLAG)) .arg(self.wallet.password_path().into_os_string()) - .arg(format!("--{}", VALIDATOR_DIR_FLAG)) - .arg(self.validator_dir.clone().into_os_string()) .arg(format!("--{}", SECRETS_DIR_FLAG)) .arg(self.secrets_dir.clone().into_os_string()) .arg(format!("--{}", DEPOSIT_GWEI_FLAG)) @@ -375,13 +375,6 @@ fn validator_create() { assert_eq!(dir_child_count(validator_dir.path()), 6); } -/// Returns the `lighthouse account validator import` command. -fn validator_import_cmd() -> Command { - let mut cmd = validator_cmd(); - cmd.arg(IMPORT_CMD); - cmd -} - #[test] fn validator_import_launchpad() { const PASSWORD: &str = "cats"; @@ -407,12 +400,13 @@ fn validator_import_launchpad() { // Create a not-keystore file in the src dir. File::create(src_dir.path().join(NOT_KEYSTORE_NAME)).unwrap(); - let mut child = validator_import_cmd() + let mut child = validator_cmd() + .arg(format!("--{}", VALIDATOR_DIR_FLAG)) + .arg(dst_dir.path().as_os_str()) + .arg(IMPORT_CMD) .arg(format!("--{}", import::STDIN_PASSWORD_FLAG)) // Using tty does not work well with tests. .arg(format!("--{}", import::DIR_FLAG)) .arg(src_dir.path().as_os_str()) - .arg(format!("--{}", VALIDATOR_DIR_FLAG)) - .arg(dst_dir.path().as_os_str()) .stderr(Stdio::piped()) .stdin(Stdio::piped()) .spawn()