1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-25 09:22:33 +00:00
trezor-firmware/tests/upgrade_tests/recovery_old.py
Roman Zeyde 7ebb00ff55 fix(core): handle DebugLink.input_wait_type when return_empty_state is set
Also, simplify `tests/upgrade_tests/recovery_old.py`.

[no changelog]
2025-05-16 11:57:55 +02:00

43 lines
1.4 KiB
Python

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from trezorlib.debuglink import DebugLink, LayoutContent
def _enter_word(debug: "DebugLink", word: str, is_slip39: bool = False) -> None:
typed_word = word[:4]
for coords in debug.button_actions.type_word(typed_word, is_slip39=is_slip39):
debug.click(coords, wait=False)
debug.click(debug.screen_buttons.mnemonic_confirm())
def confirm_recovery(debug: "DebugLink") -> None:
debug.click(debug.screen_buttons.ok())
def select_number_of_words(
debug: "DebugLink", tag_version: tuple | None, num_of_words: int = 20
) -> None:
if "SelectWordCount" not in debug.read_layout().all_components():
debug.click(debug.screen_buttons.ok())
if tag_version is None or tag_version > (2, 8, 8):
# layout changed after adding the cancel button
coords = debug.screen_buttons.word_count_all_word(num_of_words)
else:
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 = debug.screen_buttons.grid34(index % 3, index // 3)
debug.click(coords)
def enter_share(debug: "DebugLink", share: str) -> "LayoutContent":
debug.click(debug.screen_buttons.ok())
for word in share.split(" "):
_enter_word(debug, word, is_slip39=True)
return debug.read_layout()