mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-04 22:02:34 +00:00
tests: fix small irregularities
This commit is contained in:
parent
ee5443a9ec
commit
e19a58fb6e
@ -76,8 +76,7 @@ def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"):
|
|||||||
|
|
||||||
# unlock by touching
|
# unlock by touching
|
||||||
if debug.model in (models.T2B1,):
|
if debug.model in (models.T2B1,):
|
||||||
# Doing a short HTC to simulate a click
|
layout = debug.press_right()
|
||||||
layout = debug.press_right(hold_ms=100)
|
|
||||||
else:
|
else:
|
||||||
layout = debug.click(buttons.INFO)
|
layout = debug.click(buttons.INFO)
|
||||||
assert "PinKeyboard" in layout.all_components()
|
assert "PinKeyboard" in layout.all_components()
|
||||||
|
@ -20,7 +20,7 @@ import json
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Generator, Optional
|
from typing import TYPE_CHECKING, Any, Generator, Optional
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -308,11 +308,11 @@ def check_share(
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def click_info_button_tt(debug: "DebugLink"):
|
def click_info_button_tt(debug: "DebugLink") -> Generator[Any, Any, ButtonRequest]:
|
||||||
"""Click Shamir backup info button and return back."""
|
"""Click Shamir backup info button and return back."""
|
||||||
debug.press_info()
|
debug.press_info()
|
||||||
debug.press_yes()
|
debug.press_yes()
|
||||||
yield
|
return (yield)
|
||||||
|
|
||||||
|
|
||||||
def click_info_button_mercury(debug: "DebugLink"):
|
def click_info_button_mercury(debug: "DebugLink"):
|
||||||
|
@ -465,11 +465,11 @@ class InputFlowShowMultisigXPUBs(InputFlowBase):
|
|||||||
|
|
||||||
# Three xpub pages with the same testing logic
|
# Three xpub pages with the same testing logic
|
||||||
for xpub_num in range(3):
|
for xpub_num in range(3):
|
||||||
expected_title = f"MULTISIG XPUB #{xpub_num + 1}\n" + (
|
expected_title = f"multisig xpub #{xpub_num + 1}\n" + (
|
||||||
"(YOURS)" if self.index == xpub_num else "(COSIGNER)"
|
"(yours)" if self.index == xpub_num else "(cosigner)"
|
||||||
)
|
)
|
||||||
layout = self.debug.swipe_left()
|
layout = self.debug.swipe_left()
|
||||||
assert expected_title == layout.title()
|
assert expected_title == layout.title().lower()
|
||||||
content = layout.text_content().replace(" ", "")
|
content = layout.text_content().replace(" ", "")
|
||||||
assert self.xpubs[xpub_num] in content
|
assert self.xpubs[xpub_num] in content
|
||||||
|
|
||||||
@ -1019,15 +1019,15 @@ class InputFlowSignTxInformationReplacement(InputFlowBase):
|
|||||||
yield # confirm txid
|
yield # confirm txid
|
||||||
self.debug.press_right()
|
self.debug.press_right()
|
||||||
self.debug.press_right()
|
self.debug.press_right()
|
||||||
yield # confirm address
|
yield # modify amount - address
|
||||||
|
self.debug.press_right()
|
||||||
|
self.debug.press_right()
|
||||||
|
yield # modify amount - amount
|
||||||
|
self.debug.press_right()
|
||||||
|
yield # modify fee
|
||||||
self.debug.press_right()
|
self.debug.press_right()
|
||||||
self.debug.press_right()
|
self.debug.press_right()
|
||||||
self.debug.press_right()
|
self.debug.press_right()
|
||||||
yield # confirm amount
|
|
||||||
self.debug.press_right()
|
|
||||||
self.debug.press_right()
|
|
||||||
self.debug.press_right()
|
|
||||||
yield
|
|
||||||
|
|
||||||
def input_flow_t3t1(self) -> BRGeneratorType:
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
||||||
yield # confirm txid
|
yield # confirm txid
|
||||||
@ -1470,23 +1470,29 @@ class InputFlowSlip39BasicBackup(InputFlowBase):
|
|||||||
self.repeated = repeated
|
self.repeated = repeated
|
||||||
|
|
||||||
def input_flow_tt(self) -> BRGeneratorType:
|
def input_flow_tt(self) -> BRGeneratorType:
|
||||||
yield # 1. Checklist
|
if self.repeated:
|
||||||
|
assert (yield).name == "confirm_repeated_backup"
|
||||||
|
self.debug.press_yes()
|
||||||
|
|
||||||
|
assert (yield).name == "backup_intro"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 2. Number of shares (5)
|
assert (yield).name == "slip39_checklist"
|
||||||
|
self.debug.press_yes()
|
||||||
|
assert (yield).name == "slip39_shares"
|
||||||
if self.click_info:
|
if self.click_info:
|
||||||
yield from click_info_button_tt(self.debug)
|
br = yield from click_info_button_tt(self.debug)
|
||||||
yield # 3. Number of shares (5)
|
assert br.name == "slip39_shares"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 4. Checklist
|
assert (yield).name == "slip39_checklist"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 4. Threshold (3)
|
assert (yield).name == "slip39_threshold"
|
||||||
if self.click_info:
|
if self.click_info:
|
||||||
yield from click_info_button_tt(self.debug)
|
br = yield from click_info_button_tt(self.debug)
|
||||||
yield # 5. Threshold (3)
|
assert br.name == "slip39_threshold"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 6. Checklist
|
assert (yield).name == "slip39_checklist"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 7. Confirm show seeds
|
assert (yield).name == "backup_warning"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
# Mnemonic phrases
|
# Mnemonic phrases
|
||||||
@ -1738,34 +1744,36 @@ class InputFlowSlip39AdvancedBackup(InputFlowBase):
|
|||||||
self.click_info = click_info
|
self.click_info = click_info
|
||||||
|
|
||||||
def input_flow_tt(self) -> BRGeneratorType:
|
def input_flow_tt(self) -> BRGeneratorType:
|
||||||
yield # 1. Backup intro
|
assert (yield).name == "backup_intro"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 2. Checklist
|
assert (yield).name == "slip39_checklist"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 2. Set and confirm group count
|
assert (yield).name == "slip39_groups"
|
||||||
if self.click_info:
|
if self.click_info:
|
||||||
yield from click_info_button_tt(self.debug)
|
br = yield from click_info_button_tt(self.debug)
|
||||||
yield # 3. Set and confirm group count
|
assert br.name == "slip39_groups"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 4. Checklist
|
assert (yield).name == "slip39_checklist"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 4. Set and confirm group threshold
|
assert (yield).name == "slip39_group_threshold"
|
||||||
if self.click_info:
|
if self.click_info:
|
||||||
yield from click_info_button_tt(self.debug)
|
br = yield from click_info_button_tt(self.debug)
|
||||||
yield # 5. Set and confirm group threshold
|
assert br.name == "slip39_group_threshold"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # 6. Checklist
|
assert (yield).name == "slip39_checklist"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
for _ in range(5): # for each of 5 groups
|
for _ in range(5): # for each of 5 groups
|
||||||
yield # Set & Confirm number of shares
|
assert (yield).name == "slip39_shares"
|
||||||
if self.click_info:
|
if self.click_info:
|
||||||
yield from click_info_button_tt(self.debug)
|
br = yield from click_info_button_tt(self.debug)
|
||||||
|
assert br.name == "slip39_shares"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # Set & confirm share threshold value
|
assert (yield).name == "slip39_threshold"
|
||||||
if self.click_info:
|
if self.click_info:
|
||||||
yield from click_info_button_tt(self.debug)
|
br = yield from click_info_button_tt(self.debug)
|
||||||
|
assert br.name == "slip39_threshold"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # Confirm show seeds
|
assert (yield).name == "backup_warning"
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
# Mnemonic phrases - show & confirm shares for all groups
|
# Mnemonic phrases - show & confirm shares for all groups
|
||||||
@ -2114,7 +2122,7 @@ class InputFlowSlip39BasicRecoveryDryRun(InputFlowBase):
|
|||||||
yield from self.REC.input_all_slip39_shares(self.shares)
|
yield from self.REC.input_all_slip39_shares(self.shares)
|
||||||
if self.mismatch:
|
if self.mismatch:
|
||||||
yield from self.REC.warning_slip39_dryrun_mismatch()
|
yield from self.REC.warning_slip39_dryrun_mismatch()
|
||||||
else:
|
elif not self.unlock_repeated_backup:
|
||||||
yield from self.REC.success_slip39_dryrun_valid()
|
yield from self.REC.success_slip39_dryrun_valid()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import typing as t
|
||||||
|
|
||||||
from trezorlib import messages, models
|
from trezorlib import messages, models
|
||||||
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
||||||
|
|
||||||
@ -56,14 +58,14 @@ class RecoveryFlow:
|
|||||||
return layout.title() + " " + layout.text_content()
|
return layout.title() + " " + layout.text_content()
|
||||||
|
|
||||||
def confirm_recovery(self) -> BRGeneratorType:
|
def confirm_recovery(self) -> BRGeneratorType:
|
||||||
yield
|
assert (yield).name == "recover_device"
|
||||||
TR.assert_in(self._text_content(), "reset__by_continuing")
|
TR.assert_in(self._text_content(), "reset__by_continuing")
|
||||||
if self.client.model is models.T2B1:
|
if self.client.model is models.T2B1:
|
||||||
self.debug.press_right()
|
self.debug.press_right()
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
def confirm_dry_run(self) -> BRGeneratorType:
|
def confirm_dry_run(self) -> BRGeneratorType:
|
||||||
yield
|
assert (yield).name == "confirm_seedcheck"
|
||||||
TR.assert_in(self._text_content(), "recovery__check_dry_run")
|
TR.assert_in(self._text_content(), "recovery__check_dry_run")
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
@ -91,7 +93,7 @@ class RecoveryFlow:
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
def enter_your_backup(self) -> BRGeneratorType:
|
def enter_your_backup(self) -> BRGeneratorType:
|
||||||
yield
|
assert (yield).name == "recovery"
|
||||||
if self.debug.model is models.T3T1:
|
if self.debug.model is models.T3T1:
|
||||||
TR.assert_in(self._text_content(), "recovery__enter_each_word")
|
TR.assert_in(self._text_content(), "recovery__enter_each_word")
|
||||||
else:
|
else:
|
||||||
@ -107,7 +109,7 @@ class RecoveryFlow:
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
def enter_any_share(self) -> BRGeneratorType:
|
def enter_any_share(self) -> BRGeneratorType:
|
||||||
yield
|
assert (yield).name == "recovery"
|
||||||
TR.assert_in_multiple(
|
TR.assert_in_multiple(
|
||||||
self._text_content(),
|
self._text_content(),
|
||||||
["recovery__enter_any_share", "recovery__enter_each_word"],
|
["recovery__enter_any_share", "recovery__enter_each_word"],
|
||||||
@ -186,6 +188,7 @@ class RecoveryFlow:
|
|||||||
def input_number_of_words(self, num_words: int) -> BRGeneratorType:
|
def input_number_of_words(self, num_words: int) -> BRGeneratorType:
|
||||||
br = yield
|
br = yield
|
||||||
assert br.code == B.MnemonicWordCount
|
assert br.code == B.MnemonicWordCount
|
||||||
|
assert br.name == "word_count"
|
||||||
if self.client.model is models.T2B1:
|
if self.client.model is models.T2B1:
|
||||||
TR.assert_in(self.debug.read_layout().title(), "word_count__title")
|
TR.assert_in(self.debug.read_layout().title(), "word_count__title")
|
||||||
else:
|
else:
|
||||||
@ -225,7 +228,7 @@ class RecoveryFlow:
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
def success_share_group_entered(self) -> BRGeneratorType:
|
def success_share_group_entered(self) -> BRGeneratorType:
|
||||||
yield
|
assert (yield).name == "share_success"
|
||||||
TR.assert_in(self._text_content(), "recovery__you_have_entered")
|
TR.assert_in(self._text_content(), "recovery__you_have_entered")
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
@ -275,6 +278,7 @@ class RecoveryFlow:
|
|||||||
self, count_needed: int | None = None
|
self, count_needed: int | None = None
|
||||||
) -> BRGeneratorType:
|
) -> BRGeneratorType:
|
||||||
br = yield
|
br = yield
|
||||||
|
assert br.name == "recovery"
|
||||||
text = get_text_possible_pagination(self.debug, br)
|
text = get_text_possible_pagination(self.debug, br)
|
||||||
if count_needed is not None:
|
if count_needed is not None:
|
||||||
assert str(count_needed) in text
|
assert str(count_needed) in text
|
||||||
@ -283,6 +287,7 @@ class RecoveryFlow:
|
|||||||
def input_mnemonic(self, mnemonic: list[str]) -> BRGeneratorType:
|
def input_mnemonic(self, mnemonic: list[str]) -> BRGeneratorType:
|
||||||
br = yield
|
br = yield
|
||||||
assert br.code == B.MnemonicInput
|
assert br.code == B.MnemonicInput
|
||||||
|
assert br.name == "mnemonic"
|
||||||
assert "MnemonicKeyboard" in self.debug.read_layout().all_components()
|
assert "MnemonicKeyboard" in self.debug.read_layout().all_components()
|
||||||
for _, word in enumerate(mnemonic):
|
for _, word in enumerate(mnemonic):
|
||||||
self.debug.input(word)
|
self.debug.input(word)
|
||||||
@ -301,19 +306,21 @@ class RecoveryFlow:
|
|||||||
if has_groups:
|
if has_groups:
|
||||||
yield from self.success_share_group_entered()
|
yield from self.success_share_group_entered()
|
||||||
if click_info:
|
if click_info:
|
||||||
|
assert (yield).name == "recovery"
|
||||||
if self.client.model is models.T2T1:
|
if self.client.model is models.T2T1:
|
||||||
yield from self.tt_click_info()
|
yield from self.tt_click_info()
|
||||||
elif self.client.model is models.T3T1:
|
elif self.client.model is models.T3T1:
|
||||||
self.mercury_click_info()
|
self.mercury_click_info()
|
||||||
yield from self.success_more_shares_needed()
|
self.debug.press_yes()
|
||||||
|
else:
|
||||||
|
yield from self.success_more_shares_needed()
|
||||||
|
|
||||||
def tt_click_info(
|
def tt_click_info(self) -> t.Generator[t.Any, t.Any, None]:
|
||||||
self,
|
|
||||||
) -> BRGeneratorType:
|
|
||||||
# Moving through the INFO button
|
|
||||||
yield
|
|
||||||
self.debug.press_info()
|
self.debug.press_info()
|
||||||
self.debug.swipe_up()
|
br = yield
|
||||||
|
assert br.name == "show_shares"
|
||||||
|
for _ in range(br.pages):
|
||||||
|
self.debug.swipe_up()
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
def mercury_click_info(self):
|
def mercury_click_info(self):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from trezorlib import debuglink, device, messages
|
from trezorlib import debuglink, device, messages
|
||||||
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
||||||
|
from trezorlib.debuglink import message_filters
|
||||||
|
|
||||||
from ..common import MNEMONIC12
|
from ..common import MNEMONIC12
|
||||||
from ..emulators import Emulator, EmulatorWrapper
|
from ..emulators import Emulator, EmulatorWrapper
|
||||||
@ -48,9 +49,8 @@ def test_wipe_code_activate_core(core_emulator: Emulator):
|
|||||||
ret = core_emulator.client.call_raw(messages.ButtonAck())
|
ret = core_emulator.client.call_raw(messages.ButtonAck())
|
||||||
|
|
||||||
# Enter the wipe code instead of the current PIN
|
# Enter the wipe code instead of the current PIN
|
||||||
assert ret == messages.ButtonRequest(
|
expected = message_filters.ButtonRequest(code=messages.ButtonRequestType.PinEntry)
|
||||||
code=messages.ButtonRequestType.PinEntry, name="pin_device"
|
assert expected.match(ret)
|
||||||
)
|
|
||||||
core_emulator.client._raw_write(messages.ButtonAck())
|
core_emulator.client._raw_write(messages.ButtonAck())
|
||||||
core_emulator.client.debug.input(WIPE_CODE)
|
core_emulator.client.debug.input(WIPE_CODE)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user