1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 19:38:09 +00:00
trezor-firmware/tests/click_tests/recovery.py

59 lines
1.6 KiB
Python
Raw Normal View History

2019-10-25 08:07:09 +00:00
from .. import buttons
def enter_word(debug, word):
word = word[:4]
for coords in buttons.type_word(word):
debug.click(coords)
return debug.click(buttons.CONFIRM_WORD, wait=True)
def select_number_of_words(debug, num_of_words=20):
# confirm recovery
layout = debug.wait_layout()
assert layout.text.startswith("Recovery mode")
layout = debug.click(buttons.OK, wait=True)
# select number of words
assert "Select number of words" in layout.text
layout = debug.click(buttons.OK, wait=True)
assert layout.text == "WordSelector"
# click the number
word_option_offset = 6
word_options = (12, 18, 20, 24, 33)
index = word_option_offset + word_options.index(
num_of_words
) # raises if num of words is invalid
coords = buttons.grid34(index % 3, index // 3)
layout = debug.click(coords, wait=True)
assert "Enter any share" in layout.text
def enter_share(debug, share: str):
layout = debug.click(buttons.OK, wait=True)
assert layout.text == "Slip39Keyboard"
for word in share.split(" "):
layout = enter_word(debug, word)
return layout
def enter_shares(debug, shares: list):
layout = debug.read_layout()
expected_text = "Enter any share"
remaining = len(shares)
for share in shares:
assert expected_text in layout.text
layout = enter_share(debug, share)
remaining -= 1
expected_text = "RecoveryHomescreen {} more".format(remaining)
assert "You have successfully recovered your wallet" in layout.text
def finalize(debug):
layout = debug.click(buttons.OK, wait=True)
assert layout.text == "Homescreen"