mirror of
https://gitlab.com/pulsechaincom/staking-deposit-cli.git
synced 2025-01-10 21:11:21 +00:00
Adds abbreviation tests
This commit is contained in:
parent
5953f30cd6
commit
567ae36295
@ -4,6 +4,7 @@ import json
|
||||
from typing import (
|
||||
Sequence,
|
||||
)
|
||||
from unicodedata import normalize
|
||||
|
||||
from staking_deposit.utils.constants import (
|
||||
MNEMONIC_LANG_OPTIONS,
|
||||
@ -13,7 +14,7 @@ from staking_deposit.key_handling.key_derivation.mnemonic import (
|
||||
_get_word_list,
|
||||
get_seed,
|
||||
get_mnemonic,
|
||||
verify_mnemonic,
|
||||
reconstruct_mnemonic,
|
||||
)
|
||||
|
||||
|
||||
@ -45,8 +46,22 @@ def test_bip39(language: str, test: Sequence[str]) -> None:
|
||||
for _, language_test_vectors in test_vectors.items()
|
||||
for test_mnemonic in language_test_vectors]
|
||||
)
|
||||
def test_verify_mnemonic(test_mnemonic: str) -> None:
|
||||
assert verify_mnemonic(test_mnemonic, WORD_LISTS_PATH) is not None
|
||||
def test_reconstruct_mnemonic(test_mnemonic: str) -> None:
|
||||
assert reconstruct_mnemonic(test_mnemonic, WORD_LISTS_PATH) is not None
|
||||
|
||||
def abbreviate_mnemonic(mnemonic: str) -> str:
|
||||
words = str.split(mnemonic)
|
||||
words = [normalize('NFKC', word) for word in words]
|
||||
return str.join(' ', words)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'test_mnemonic',
|
||||
[abbreviate_mnemonic(test_mnemonic[1])
|
||||
for _, language_test_vectors in test_vectors.items()
|
||||
for test_mnemonic in language_test_vectors]
|
||||
)
|
||||
def test_reconstruct_abbreviated_mnemonic(test_mnemonic: str) -> None:
|
||||
assert reconstruct_mnemonic(test_mnemonic, WORD_LISTS_PATH) is not None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
Loading…
Reference in New Issue
Block a user