What changed, and why it matters
This commit only adds new automated tests for the wallet login flow. It does not change any production code, so it cannot introduce a security vulnerability or fix one directly. The tests verify that menu navigation works correctly when a user creates a new wallet from a generated mnemonic versus loading an existing one.
No security action needed. Review as normal test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds two unit tests to tests/pages/test_login.py. test_generated_mnemonic_wallet_options_return_to_summary mocks the Menu, PassphraseEditor, and WalletSettings classes to simulate a user selecting ‘Wallet Options’ and then returning, asserting the correct menu labels and that the passphrase editor and wallet customizer are each called once. test_loaded_mnemonic_keeps_direct_wallet_actions verifies that loading an existing mnemonic presents a menu with direct ‘Load Wallet’, ‘Passphrase’, and ‘Customize’ options. No application logic in src/ is modified.
Changed components
tests/pages/test_login.pyInspect captured patch +94 / −0
diff --git a/tests/pages/test_login.py b/tests/pages/test_login.py
index c802a4c..33d189b 100644
--- a/tests/pages/test_login.py
+++ b/tests/pages/test_login.py
@@ -1459,6 +1459,100 @@ def test_customization_while_loading_wallet(amigo, mocker):
assert "krux.pages.wallet_settings" in sys.modules
+def test_generated_mnemonic_wallet_options_return_to_summary(amigo, mocker):
+ from krux.pages import MENU_CONTINUE, MENU_EXIT
+ from krux.pages.login import Login
+ from krux.pages.wallet_settings import PassphraseEditor, WalletSettings
+ from krux.krux_settings import Settings
+
+ mnemonic = "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo daring"
+ Settings().security.hide_mnemonic = True
+
+ ctx = create_ctx(mocker, [])
+ login = Login(ctx)
+ discard_prompt = mocker.patch.object(login, "prompt", return_value=False)
+
+ passphrase_editor = mocker.patch.object(
+ PassphraseEditor,
+ "load_passphrase_menu",
+ return_value="secret",
+ )
+ wallet_settings = mocker.patch.object(
+ WalletSettings,
+ "customize_wallet",
+ side_effect=lambda key: (
+ key.network,
+ key.policy_type,
+ key.script_type,
+ key.account_index,
+ key.derivation,
+ ),
+ )
+
+ menu_selections = iter([1, 2, 2, 1, 0, 1, 1, 0])
+ menu_labels = []
+
+ class MenuStub:
+ def __init__(self, _ctx, menu, **_kwargs):
+ self.menu = menu + [("< Back", lambda: MENU_EXIT)]
+ menu_labels.append([label for label, _ in self.menu])
+
+ @property
+ def back_index(self):
+ return len(self.menu) - 1
+
+ def run_loop(self):
+ return next(menu_selections), MENU_CONTINUE
+
+ mocker.patch("krux.pages.login.Menu", MenuStub)
+
+ assert login._load_key_from_words(mnemonic.split(), new=True) == MENU_EXIT
+ assert menu_labels == [
+ ["Continue", "Wallet Options", "< Back"],
+ ["Passphrase", "Customize", "< Back"],
+ ["Continue", "Wallet Options", "< Back"],
+ ["Continue", "Wallet Options", "< Back"],
+ ["Passphrase", "Customize", "< Back"],
+ ["Continue", "Wallet Options", "< Back"],
+ ["Passphrase", "Customize", "< Back"],
+ ["Continue", "Wallet Options", "< Back"],
+ ]
+ discard_prompt.assert_called_once()
+ passphrase_editor.assert_called_once_with(mnemonic)
+ wallet_settings.assert_called_once()
+ assert ctx.wallet.key.passphrase == "secret"
+
+
+def test_loaded_mnemonic_keeps_direct_wallet_actions(amigo, mocker):
+ from krux.pages import MENU_CONTINUE, MENU_EXIT
+ from krux.pages.login import Login
+ from krux.krux_settings import Settings
+
+ mnemonic = "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo daring"
+ Settings().security.hide_mnemonic = True
+
+ ctx = create_ctx(mocker, [])
+ login = Login(ctx)
+ menu_labels = []
+
+ class MenuStub:
+ def __init__(self, _ctx, menu, **_kwargs):
+ self.menu = menu + [("< Back", lambda: MENU_EXIT)]
+ menu_labels.append([label for label, _ in self.menu])
+
+ @property
+ def back_index(self):
+ return len(self.menu) - 1
+
+ def run_loop(self):
+ return 0, MENU_CONTINUE
+
+ mocker.patch("krux.pages.login.Menu", MenuStub)
+
+ assert login._load_key_from_words(mnemonic.split()) == MENU_EXIT
+ assert menu_labels == [["Load Wallet", "Passphrase", "Customize", "< Back"]]
+
+
def test_about(mocker, multiple_devices):
from krux.pages.login import Login
import board
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.