Skip to content

Commit

Permalink
BIP85 passwords: add spec test case
Browse files Browse the repository at this point in the history
  • Loading branch information
odudex committed Oct 24, 2024
1 parent 290cddc commit ecf9342
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/pages/home_pages/test_bip85.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ def test_bip85_base64_password_derivation(mocker, amigo, tdata):
from krux.pages.home_pages.bip85 import Bip85
from krux.wallet import Wallet
from krux.input import BUTTON_ENTER, BUTTON_PAGE, BUTTON_PAGE_PREV
from krux.settings import TEST_TXT
from embit import bip32
from embit.networks import NETWORKS

cases = [
# case
Expand Down Expand Up @@ -307,14 +310,38 @@ def test_bip85_base64_password_derivation(mocker, amigo, tdata):
None,
True,
),
# 6 - Test xprv example from BIP85 spec
(
"xprv9s21ZrQH143K2LBWUUQRFXhucrQqBpKdRRxNVq2zBqsx8HVqFk2uYo8kmbaLLHRdqtQpUm98uKfu3vca1LqdGhUtyoFnCNkfmXRyPXLjbKb",
[
BUTTON_PAGE, # Move to "Base64 Password"
BUTTON_ENTER, # Confirm
*([BUTTON_PAGE_PREV] * 4), # Type 21 characters
BUTTON_ENTER, # Index 0
*([BUTTON_PAGE] * 3), # Move to "Go"
BUTTON_ENTER, # Go
# Keep length = 21
BUTTON_PAGE_PREV, # Move to "Go"
BUTTON_ENTER, # Go
BUTTON_PAGE_PREV, # Move to "< Back"
BUTTON_ENTER, # Leave
],
"dKLoepugzdVJvdL56ogNV\n\nIndex: 0\nLength: 21",
),
]
mock_save_file = mocker.patch(
"krux.pages.file_operations.SaveFile.save_file",
)
case_num = 0
for case in cases:
print(case_num)
wallet = Wallet(case[0])
if isinstance(case[0], str):
# Create a dummy wallet
wallet = Wallet(cases[0][0])
# Replace root with the xprv
wallet.key.root = bip32.HDKey.from_string(case[0])
else:
wallet = Wallet(case[0])
ctx = create_ctx(mocker, case[1], wallet)
mocker.spy(ctx.display, "draw_hcentered_text")
bip85_ui = Bip85(ctx)
Expand Down

0 comments on commit ecf9342

Please sign in to comment.