Skip to content

Commit

Permalink
Minor refactoring of wallet e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
karbyshev committed Jan 18, 2024
1 parent 8120ab7 commit 9d47d91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/tests/src/e2e/wallet_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ use color_eyre::eyre::Result;
use super::setup;
use crate::e2e::setup::Bin;
use crate::run;
use crate::strings::{
WALLET_FOUND_TRANSPARENT_KEYS, WALLET_HD_PASSPHRASE_PROMPT,
};

/// Test wallet key commands with an encrypted key:
/// 1. key gen
Expand All @@ -35,7 +38,7 @@ fn wallet_encrypted_key_cmds() -> Result<()> {
cmd.send_line(password)?;
cmd.exp_string("Enter same passphrase again: ")?;
cmd.send_line(password)?;
cmd.exp_string("Enter BIP39 passphrase (empty for none): ")?;
cmd.exp_string(WALLET_HD_PASSPHRASE_PROMPT)?;
cmd.send_line("")?;
cmd.exp_string(&format!(
"Successfully added a key and an address with alias: \"{}\"",
Expand All @@ -50,7 +53,7 @@ fn wallet_encrypted_key_cmds() -> Result<()> {
Some(20),
)?;

cmd.exp_string("Found transparent keys:")?;
cmd.exp_string(WALLET_FOUND_TRANSPARENT_KEYS)?;
cmd.exp_string(&format!(
" Alias \"{}\" (encrypted):",
key_alias.to_lowercase()
Expand Down Expand Up @@ -86,7 +89,7 @@ fn wallet_encrypted_key_cmds_env_var() -> Result<()> {
let mut cmd =
run!(test, Bin::Wallet, &["gen", "--alias", key_alias], Some(20),)?;

cmd.exp_string("Enter BIP39 passphrase (empty for none): ")?;
cmd.exp_string(WALLET_HD_PASSPHRASE_PROMPT)?;
cmd.send_line("")?;

cmd.exp_string(&format!(
Expand All @@ -102,7 +105,7 @@ fn wallet_encrypted_key_cmds_env_var() -> Result<()> {
Some(20),
)?;

cmd.exp_string("Found transparent keys:")?;
cmd.exp_string(WALLET_FOUND_TRANSPARENT_KEYS)?;
cmd.exp_string(&format!(
" Alias \"{}\" (encrypted):",
key_alias.to_lowercase()
Expand Down Expand Up @@ -137,7 +140,7 @@ fn wallet_unencrypted_key_cmds() -> Result<()> {
Some(20),
)?;

cmd.exp_string("Enter BIP39 passphrase (empty for none): ")?;
cmd.exp_string(WALLET_HD_PASSPHRASE_PROMPT)?;
cmd.send_line("")?;

cmd.exp_string(&format!(
Expand All @@ -153,7 +156,7 @@ fn wallet_unencrypted_key_cmds() -> Result<()> {
Some(20),
)?;

cmd.exp_string("Found transparent keys:")?;
cmd.exp_string(WALLET_FOUND_TRANSPARENT_KEYS)?;
cmd.exp_string(&format!(
" Alias \"{}\" (not encrypted):",
key_alias.to_lowercase()
Expand Down
5 changes: 5 additions & 0 deletions crates/tests/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ pub const TX_FAILED: &str = "Transaction failed";

/// Wrapper transaction accepted.
pub const TX_ACCEPTED: &str = "Wrapper transaction accepted";

pub const WALLET_HD_PASSPHRASE_PROMPT: &str =
"Enter BIP39 passphrase (empty for none): ";

pub const WALLET_FOUND_TRANSPARENT_KEYS: &str = "Found transparent keys:";

0 comments on commit 9d47d91

Please sign in to comment.