mirror of https://github.com/nucypher/nucypher.git
return tuple when interactive=False
parent
55d009b667
commit
2d1b37f9aa
|
@ -346,12 +346,8 @@ class Keystore:
|
|||
cls, password: str,
|
||||
keystore_dir: Optional[Path] = None,
|
||||
interactive: bool = True,
|
||||
return_mnemonic: bool = False
|
||||
) -> Union['Keystore', Tuple['Keystore', str]]:
|
||||
"""Generate a new nucypher keystore for use with characters"""
|
||||
if return_mnemonic and interactive:
|
||||
raise ValueError("The two values: report_mnemonic and interactive, may not both be `True`")
|
||||
|
||||
mnemonic = Mnemonic(_MNEMONIC_LANGUAGE)
|
||||
__words = mnemonic.generate(strength=_ENTROPY_BITS)
|
||||
if interactive:
|
||||
|
@ -360,10 +356,10 @@ class Keystore:
|
|||
path = Keystore.__save(secret=__secret, password=password, keystore_dir=keystore_dir)
|
||||
keystore = cls(keystore_path=path)
|
||||
|
||||
if return_mnemonic:
|
||||
return keystore, __words
|
||||
if interactive:
|
||||
return keystore
|
||||
|
||||
return keystore
|
||||
return keystore, __words
|
||||
|
||||
@staticmethod
|
||||
def _confirm_generate(__words: str) -> None:
|
||||
|
|
|
@ -116,20 +116,14 @@ def test_keystore_invalid_password(tmpdir):
|
|||
_keystore = Keystore.generate('short', keystore_dir=tmpdir)
|
||||
|
||||
|
||||
def test_keystore_generate_report_mnemonic_true(tmpdir):
|
||||
def test_keystore_generate_report_interactive_false(tmpdir):
|
||||
_keystore, words = Keystore.generate(
|
||||
INSECURE_DEVELOPMENT_PASSWORD,
|
||||
keystore_dir=tmpdir,
|
||||
interactive=False,
|
||||
return_mnemonic=True)
|
||||
interactive=False)
|
||||
assert len(words.split(" ")) == 24
|
||||
|
||||
|
||||
def test_keystore_generate_report_mnemonic_blocked_by_interactive(tmpdir):
|
||||
with pytest.raises(ValueError, match="The two values: report_mnemonic and interactive, may not both be `True`"):
|
||||
_keystore = Keystore.generate(INSECURE_DEVELOPMENT_PASSWORD, keystore_dir=tmpdir, return_mnemonic=True)
|
||||
|
||||
|
||||
def test_keystore_derive_crypto_power_without_unlock(tmpdir):
|
||||
keystore = Keystore.generate(INSECURE_DEVELOPMENT_PASSWORD, keystore_dir=tmpdir)
|
||||
with pytest.raises(Keystore.Locked):
|
||||
|
|
Loading…
Reference in New Issue