From b05a16d6494ba08c26eede94464c79ff545c78ae Mon Sep 17 00:00:00 2001 From: kdmukai Date: Fri, 3 Mar 2023 11:37:43 -0600 Subject: [PATCH] misc bugfixes, improvements --- tests/README.md | 2 +- tests/test_mnemonic_generation.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/README.md b/tests/README.md index f648de73..ae8679c6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -33,7 +33,7 @@ coverage run -m pytest Show the resulting test coverage details: ``` -coverage report --show-missing +coverage report ``` Generate the html overview: diff --git a/tests/test_mnemonic_generation.py b/tests/test_mnemonic_generation.py index f84ffacb..76298d34 100644 --- a/tests/test_mnemonic_generation.py +++ b/tests/test_mnemonic_generation.py @@ -51,21 +51,25 @@ def test_calculate_checksum_invalid_mnemonics(): # Mnemonic is too short: 10 words instead of 11 partial_mnemonic = "abandon " * 9 + "about" mnemonic_generation.calculate_checksum(partial_mnemonic.split(" "), wordlist_language_code=SettingsConstants.WORDLIST_LANGUAGE__ENGLISH) + assert "12- or 24-word" in str(e) with pytest.raises(Exception) as e: # Valid mnemonic but unsupported length mnemonic = "devote myth base logic dust horse nut collect buddy element eyebrow visit empty dress jungle" mnemonic_generation.calculate_checksum(mnemonic.split(" "), wordlist_language_code=SettingsConstants.WORDLIST_LANGUAGE__ENGLISH) + assert "12- or 24-word" in str(e) with pytest.raises(Exception) as e: # Mnemonic is too short: 22 words instead of 23 partial_mnemonic = "abandon " * 21 + "about" mnemonic_generation.calculate_checksum(partial_mnemonic.split(" "), wordlist_language_code=SettingsConstants.WORDLIST_LANGUAGE__ENGLISH) + assert "12- or 24-word" in str(e) - with pytest.raises(Exception) as e: + with pytest.raises(ValueError) as e: # Invalid BIP-39 word - partial_mnemonic = "foobar " * 9 + "about" + partial_mnemonic = "foobar " * 11 + "about" mnemonic_generation.calculate_checksum(partial_mnemonic.split(" "), wordlist_language_code=SettingsConstants.WORDLIST_LANGUAGE__ENGLISH) + assert "not in the dictionary" in str(e)