Skip to content

Commit

Permalink
test for bad input, improve help text
Browse files Browse the repository at this point in the history
  • Loading branch information
akarve committed Jun 6, 2024
1 parent 40dbac4 commit 9faba14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bipsea/bipsea.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def bip39_cmd(from_, to, input, number, passphrase, pretty):
words = normalize_list(re.split(r"\s+", input), lower=True)
if language and not verify_seed_words(words, language):
raise click.BadParameter(
f"--input mnemonic not in {from_} or has bad checksum.",
f"--input mnemonic not in {ISO_TO_LANGUAGE[from_]} wordlist or has bad checksum.",
param_hint="--input",
)
if from_ == "any":
Expand Down
10 changes: 9 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def test_seed_option_sensitivity(runner, language, vectors):
result = runner.invoke(cli, cmd)
if suffix == ".":
assert result.exit_code != 0
assert lang_code in result.output
assert ISO_TO_LANGUAGE[lang_code] in result.output
assert "not in" in result.output
else:
assert result.exit_code == 0
result_xprv = result.output.strip().split("\n")[-1]
Expand Down Expand Up @@ -242,3 +243,10 @@ def test_entropy_wif(runner, vector):
result = runner.invoke(cli, ["entropy", "-a", "wif", "--input", xprv])
assert result.exit_code == 0
assert result.output.strip() == vector["derived_wif"]


def test_seed_bad_input(runner):
phrase = "きわめる そせい ばかり なみだ みつかる くしゃみ にあう ひみつ かくとく よけい げんき ほきょう"
result = runner.invoke(cli, ["seed", "-f", "spa", "--input", phrase])
assert result.exit_code != 0
assert "not in spa" in result.output

0 comments on commit 9faba14

Please sign in to comment.