Ensure API create_wallet returns failure when provided with invalid mnemonic seeds (#319)

* Ensure  returns failure with invalid mnemonic seeds, add tests

* test fixes resulting from change
This commit is contained in:
Yeastplume
2020-01-31 12:00:49 +00:00
committed by GitHub
parent e71d79dc38
commit ed5b9008c0
6 changed files with 51 additions and 3 deletions
+3 -1
View File
@@ -150,6 +150,7 @@ impl WalletSeed {
seed_length: usize,
recovery_phrase: Option<util::ZeroingString>,
password: util::ZeroingString,
test_mode: bool,
) -> Result<WalletSeed, Error> {
// create directory if it doesn't exist
fs::create_dir_all(data_file_dir).context(ErrorKind::IO)?;
@@ -158,8 +159,9 @@ impl WalletSeed {
warn!("Generating wallet seed file at: {}", seed_file_path);
let exists = WalletSeed::seed_file_exists(data_file_dir)?;
if exists {
if exists && !test_mode {
let msg = format!("Wallet seed already exists at: {}", data_file_dir);
error!("{}", msg);
return Err(ErrorKind::WalletSeedExists(msg))?;
}