1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-19 05:58:09 +00:00

tests: fix input_flows

Reset/recovery tests after adding Wallet created screen and separate
backup intro.

Regen signatures.json after rebase.

[no changelog]
This commit is contained in:
obrusvit 2024-06-04 15:40:42 +02:00 committed by matejcik
parent fd59c2ce88
commit e30de62adc
11 changed files with 178 additions and 91 deletions

View File

@ -1407,7 +1407,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
paragraphs
.add(Paragraph::new(
&theme::TEXT_NORMAL,
TR::recovery__only_first_n_letters,
TR::recovery__enter_each_word,
))
.add(Paragraph::new(
&theme::TEXT_NORMAL,

View File

@ -123,7 +123,7 @@ async def continue_recovery(
if show_info:
# Show this just one-time
description = TR.recovery__only_first_n_letters
description = TR.recovery__enter_each_word
else:
description = subtext or ""

View File

@ -1,8 +1,8 @@
{
"current": {
"merkle_root": "405ce2be8dcb492a1d4b25ec8aaeaa9914ff88594151beaceea52315172b11d0",
"datetime": "2024-06-03T12:40:07.498873",
"commit": "2ac4967ef190dac1fe238cc00878ff2d08e17bb5"
"merkle_root": "ba305d41fa4793fc71a2cd124cd9170ce93177f0a749ea0444c2f06cc3a65d2b",
"datetime": "2024-06-05T14:49:38.622932",
"commit": "7322ca7ddb4539885970f4546494369e1ff950f8"
},
"history": [
{

View File

@ -108,7 +108,10 @@ def select_number_of_words(
if debug.model in (models.T2B1,):
TR.assert_in(layout.text_content(), "recovery__enter_backup")
else:
TR.assert_in(layout.text_content(), "recovery__only_first_n_letters")
TR.assert_in_multiple(
layout.text_content(),
["recovery__only_first_n_letters", "recovery__enter_each_word"],
)
elif num_of_words in (20, 33):
TR.assert_in_multiple(
layout.text_content(),
@ -116,12 +119,17 @@ def select_number_of_words(
"recovery__enter_backup",
"recovery__enter_any_share",
"recovery__only_first_n_letters",
"recovery__enter_each_word",
],
)
else: # BIP-39
TR.assert_in_multiple(
layout.text_content(),
["recovery__enter_backup", "recovery__only_first_n_letters"],
[
"recovery__enter_backup",
"recovery__only_first_n_letters",
"recovery__enter_each_word",
],
)
@ -163,6 +171,7 @@ def enter_shares(
"recovery__enter_backup",
"recovery__enter_any_share",
"recovery__only_first_n_letters",
"recovery__enter_each_word",
text,
],
)
@ -247,7 +256,12 @@ def prepare_enter_seed(
) -> None:
TR.assert_in_multiple(
debug.read_layout().text_content(),
["recovery__enter_backup", "recovery__only_first_n_letters", layout_text],
[
"recovery__enter_backup",
"recovery__only_first_n_letters",
"recovery__enter_each_word",
layout_text,
],
)
if debug.model in (models.T2T1,):
debug.click(buttons.OK, wait=True)

View File

@ -125,7 +125,7 @@ def confirm_words(debug: "DebugLink", words: list[str]) -> None:
debug.swipe_up(wait=True)
layout = debug.wait_layout()
if debug.model in (models.T2T1, models.T3T1):
if debug.model in (models.T2T1,):
TR.assert_template(layout.text_content(), "reset__select_word_x_of_y_template")
for _ in range(3):
# "Select word 3 of 20"
@ -139,11 +139,22 @@ def confirm_words(debug: "DebugLink", words: list[str]) -> None:
]
wanted_word = words[word_pos - 1].lower()
button_pos = btn_texts.index(wanted_word)
if debug.model is models.T3T1:
btn_positions = buttons.VERTICAL_MENU
else:
btn_positions = buttons.RESET_WORD_CHECK
layout = debug.click(btn_positions[button_pos], wait=True)
layout = debug.click(buttons.RESET_WORD_CHECK[button_pos], wait=True)
elif debug.model in (models.T3T1,):
TR.assert_template(layout.subtitle(), "reset__select_word_x_of_y_template")
for _ in range(3):
# "Select word 3 of 20"
# ^
word_pos_match = re.search(r"\d+", debug.wait_layout().subtitle())
assert word_pos_match is not None
word_pos = int(word_pos_match.group(0))
# Unifying both the buttons and words to lowercase
btn_texts = [
text.lower() for text in layout.tt_check_seed_button_contents()
]
wanted_word = words[word_pos - 1].lower()
button_pos = btn_texts.index(wanted_word)
layout = debug.click(buttons.VERTICAL_MENU[button_pos], wait=True)
elif debug.model in (models.T2B1,):
TR.assert_in(layout.text_content(), "reset__select_correct_word")
layout = debug.press_right(wait=True)

View File

@ -18,7 +18,7 @@ from typing import TYPE_CHECKING
import pytest
from trezorlib import device, messages
from trezorlib import device, messages, models
from ..common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy
from . import reset
@ -78,6 +78,9 @@ def test_backup_slip39_custom(
if share_count > 1:
# confirm shamir warning
reset.confirm_read(debug, middle_r=True)
else:
# confirm backup intro
reset.confirm_read(debug, middle_r=True)
all_words: list[str] = []
for _ in range(share_count):
@ -93,7 +96,10 @@ def test_backup_slip39_custom(
all_words.append(" ".join(words))
# confirm backup done
reset.confirm_read(debug)
if debug.model is models.T3T1 and share_count > 1:
reset.confirm_read(debug)
elif debug.model != models.T3T1:
reset.confirm_read(debug)
# generate secret locally
internal_entropy = debug.state().reset_entropy

View File

@ -55,6 +55,9 @@ def test_repeated_backup(
# confirm back up
reset.confirm_read(debug)
# confirm backup intro
reset.confirm_read(debug)
# confirm backup warning
reset.confirm_read(debug, middle_r=True)
@ -138,6 +141,9 @@ def test_repeated_backup(
debug.wait_layout()
# confirm backup intro
reset.confirm_read(debug)
# confirm checklist
reset.confirm_read(debug)

View File

@ -52,6 +52,9 @@ def test_reset_bip39(device_handler: "BackgroundDeviceHandler"):
# confirm back up
reset.confirm_read(debug)
# confirm backup intro
reset.confirm_read(debug, middle_r=True)
# confirm backup warning
reset.confirm_read(debug, middle_r=True)

View File

@ -64,6 +64,9 @@ def test_reset_slip39_advanced(
# confirm back up
reset.confirm_read(debug)
# confirm backup intro
reset.confirm_read(debug)
# confirm checklist
reset.confirm_read(debug)

View File

@ -61,6 +61,9 @@ def test_reset_slip39_basic(
# confirm back up
reset.confirm_read(debug)
# confirm backup intro
reset.confirm_read(debug)
# confirm checklist
reset.confirm_read(debug)

View File

@ -1275,8 +1275,9 @@ class InputFlowBip39Backup(InputFlowBase):
self.mnemonic = None
def input_flow_common(self) -> BRGeneratorType:
# 1. Confirm Reset
yield from click_through(self.debug, screens=1, code=B.ResetDevice)
# 1. Backup intro
# 2. Backup warning
yield from click_through(self.debug, screens=2, code=B.ResetDevice)
# mnemonic phrases and rest
self.mnemonic = yield from get_mnemonic_and_confirm_success(self.debug)
@ -1291,8 +1292,9 @@ class InputFlowBip39ResetBackup(InputFlowBase):
def input_flow_tt(self) -> BRGeneratorType:
# 1. Confirm Reset
# 2. Backup your seed
# 3. Confirm warning
yield from click_through(self.debug, screens=3, code=B.ResetDevice)
# 3. Backup intro
# 4. Confirm warning
yield from click_through(self.debug, screens=4, code=B.ResetDevice)
# mnemonic phrases and rest
self.mnemonic = yield from get_mnemonic_and_confirm_success(self.debug)
@ -1300,16 +1302,19 @@ class InputFlowBip39ResetBackup(InputFlowBase):
def input_flow_tr(self) -> BRGeneratorType:
# 1. Confirm Reset
# 2. Backup your seed
# 3. Confirm warning
yield from click_through(self.debug, screens=3, code=B.ResetDevice)
# 3. Backup intro
# 4. Confirm warning
yield from click_through(self.debug, screens=4, code=B.ResetDevice)
# mnemonic phrases and rest
self.mnemonic = yield from get_mnemonic_and_confirm_success(self.debug)
def input_flow_t3t1(self) -> BRGeneratorType:
# 1. Confirm Reset x3
# 2. Backup your seed
# 3. Confirm warning
# 1. Confirm Reset
# 2. Wallet created
# 3. Backup your seed
# 4. Backup intro
# 5. Confirm warning
yield from click_through(self.debug, screens=5, code=B.ResetDevice)
# mnemonic phrases and rest
@ -1345,6 +1350,10 @@ class InputFlowBip39ResetPIN(InputFlowBase):
assert br.code == B.ResetDevice
self.debug.press_yes()
br = yield # Backup intro
assert br.code == B.ResetDevice
self.debug.press_yes()
# mnemonic phrases
self.mnemonic = yield from read_and_confirm_mnemonic(self.debug)
@ -1363,11 +1372,12 @@ class InputFlowBip39ResetFailedCheck(InputFlowBase):
self.mnemonic = None
def input_flow_common(self) -> BRGeneratorType:
screens = 4 if self.debug.model is models.T3T1 else 3
screens = 5 if self.debug.model is models.T3T1 else 4
# 1. Confirm Reset
# 1a. (T3T1) done
# 2. Backup your seed
# 3. Confirm warning
# 1a. (T3T1) Walet Creation done
# 2. Confirm backup prompt
# 3. Backup your seed
# 4. Confirm warning
yield from click_through(self.debug, screens=screens, code=B.ResetDevice)
# mnemonic phrases, wrong answer
@ -1417,21 +1427,23 @@ class InputFlowSlip39BasicBackup(InputFlowBase):
self.click_info = click_info
def input_flow_tt(self) -> BRGeneratorType:
yield # 1. Checklist
yield # 1. Backup intro
self.debug.press_yes()
yield # 2. Checklist
self.debug.press_yes()
if self.click_info:
yield from click_info_button_tt(self.debug)
yield # 2. Number of shares (5)
yield # 3. Number of shares (5)
self.debug.press_yes()
yield # 3. Checklist
yield # 4. Checklist
self.debug.press_yes()
if self.click_info:
yield from click_info_button_tt(self.debug)
yield # 4. Threshold (3)
yield # 5. Threshold (3)
self.debug.press_yes()
yield # 5. Checklist
yield # 6. Checklist
self.debug.press_yes()
yield # 6. Confirm show seeds
yield # 7. Confirm show seeds
self.debug.press_yes()
# Mnemonic phrases
@ -1442,21 +1454,23 @@ class InputFlowSlip39BasicBackup(InputFlowBase):
self.debug.press_yes()
def input_flow_tr(self) -> BRGeneratorType:
yield # 1. Checklist
yield # 1. Backup intro
self.debug.press_yes()
yield # 1.5 Number of shares info
yield # 2. Checklist
self.debug.press_yes()
yield # 2. Number of shares (5)
yield # 2.5 Number of shares info
self.debug.press_yes()
yield # 3. Number of shares (5)
self.debug.input("5")
yield # 3. Checklist
yield # 4. Checklist
self.debug.press_yes()
yield # 3.5 Threshold info
yield # 4.5 Threshold info
self.debug.press_yes()
yield # 4. Threshold (3)
yield # 5. Threshold (3)
self.debug.input("3")
yield # 5. Checklist
yield # 6. Checklist
self.debug.press_yes()
yield # 6. Confirm show seeds
yield # 7. Confirm show seeds
self.debug.press_yes()
# Mnemonic phrases
@ -1467,22 +1481,25 @@ class InputFlowSlip39BasicBackup(InputFlowBase):
self.debug.press_yes()
def input_flow_t3t1(self) -> BRGeneratorType:
yield # 1. Checklist
yield # 1. Backup intro
self.debug.wait_layout()
self.debug.swipe_up()
yield # 2. Checklist
self.debug.wait_layout()
self.debug.swipe_up(wait=True)
if self.click_info:
click_info_button_mercury(self.debug)
yield # 2. Number of shares (5)
yield # 3. Number of shares (5)
self.debug.swipe_up()
yield # 3. Checklist
yield # 4. Checklist
self.debug.swipe_up(wait=True)
if self.click_info:
click_info_button_mercury(self.debug)
yield # 4. Threshold (3)
yield # 5. Threshold (3)
self.debug.swipe_up()
yield # 5. Checklist
yield # 6. Checklist
self.debug.swipe_up()
yield # 6. Confirm show seeds
yield # 7. Confirm show seeds
self.debug.swipe_up()
# Mnemonic phrases
@ -1501,13 +1518,14 @@ class InputFlowSlip39BasicResetRecovery(InputFlowBase):
def input_flow_tt(self) -> BRGeneratorType:
# 1. Confirm Reset
# 2. Backup your seed
# 3. Confirm warning
# 4. shares info
# 5. Set & Confirm number of shares
# 6. threshold info
# 7. Set & confirm threshold value
# 8. Confirm show seeds
yield from click_through(self.debug, screens=8, code=B.ResetDevice)
# 3. Backup intro
# 4. Confirm warning
# 5. shares info
# 6. Set & Confirm number of shares
# 7. threshold info
# 8. Set & confirm threshold value
# 9. Confirm show seeds
yield from click_through(self.debug, screens=9, code=B.ResetDevice)
# Mnemonic phrases
self.mnemonics = yield from load_N_shares(self.debug, 5)
@ -1521,6 +1539,8 @@ class InputFlowSlip39BasicResetRecovery(InputFlowBase):
self.debug.press_yes()
yield # Backup your seed
self.debug.press_yes()
yield # Backup intro
self.debug.press_yes()
yield # Checklist
self.debug.press_yes()
yield # Number of shares info
@ -1547,9 +1567,9 @@ class InputFlowSlip39BasicResetRecovery(InputFlowBase):
def input_flow_t3t1(self) -> BRGeneratorType:
# 1. Confirm Reset
# 2. Backup your seed
# 3. Confirm warning
# 4. shares info
# 2. Wallet Created
# 3. Backup your seed
# 4. Backup intro
# 5. Set & Confirm number of shares
# 6. threshold info
# 7. Set & confirm threshold value
@ -1576,6 +1596,9 @@ class InputFlowSlip39CustomBackup(InputFlowBase):
if self.share_count > 1:
yield # Checklist
self.debug.press_yes()
else:
yield # Backup intro
self.debug.press_yes()
yield # Confirm show seeds
self.debug.press_yes()
@ -1591,6 +1614,9 @@ class InputFlowSlip39CustomBackup(InputFlowBase):
if self.share_count > 1:
yield # Checklist
self.debug.press_yes()
else:
yield # Backup intro
self.debug.press_yes()
yield # Confirm show seeds
self.debug.press_yes()
@ -1606,6 +1632,9 @@ class InputFlowSlip39CustomBackup(InputFlowBase):
if self.share_count > 1:
yield # Checklist
self.debug.press_yes()
else:
yield # Backup intro
self.debug.press_yes()
yield # Confirm show seeds
self.debug.press_yes()
@ -1643,19 +1672,21 @@ class InputFlowSlip39AdvancedBackup(InputFlowBase):
self.click_info = click_info
def input_flow_tt(self) -> BRGeneratorType:
yield # 1. Checklist
yield # 1. Backup intro
self.debug.press_yes()
yield # 2. Checklist
self.debug.press_yes()
if self.click_info:
yield from click_info_button_tt(self.debug)
yield # 2. Set and confirm group count
yield # 3. Set and confirm group count
self.debug.press_yes()
yield # 3. Checklist
yield # 4. Checklist
self.debug.press_yes()
if self.click_info:
yield from click_info_button_tt(self.debug)
yield # 4. Set and confirm group threshold
yield # 5. Set and confirm group threshold
self.debug.press_yes()
yield # 5. Checklist
yield # 6. Checklist
self.debug.press_yes()
for _ in range(5): # for each of 5 groups
if self.click_info:
@ -1677,15 +1708,17 @@ class InputFlowSlip39AdvancedBackup(InputFlowBase):
self.debug.press_yes()
def input_flow_tr(self) -> BRGeneratorType:
yield # 1. Checklist
yield # 1. Backup intro
self.debug.press_yes()
yield # 2. Set and confirm group count
yield # 2. Checklist
self.debug.press_yes()
yield # 3. Set and confirm group count
self.debug.input("5")
yield # 3. Checklist
yield # 4. Checklist
self.debug.press_yes()
yield # 4. Set and confirm group threshold
yield # 5. Set and confirm group threshold
self.debug.input("3")
yield # 5. Checklist
yield # 6. Checklist
self.debug.press_yes()
for _ in range(5): # for each of 5 groups
yield # Number of shares info
@ -1707,19 +1740,22 @@ class InputFlowSlip39AdvancedBackup(InputFlowBase):
self.debug.press_yes()
def input_flow_t3t1(self) -> BRGeneratorType:
yield # 1. Checklist
yield # 1. Backup intro
self.debug.wait_layout()
self.debug.swipe_up()
yield # 2. Checklist
self.debug.swipe_up(wait=True)
if self.click_info:
click_info_button_mercury(self.debug)
yield # 2. Set and confirm group count
yield # 3. Set and confirm group count
self.debug.swipe_up()
yield # 3. Checklist
yield # 4. Checklist
self.debug.swipe_up(wait=True)
if self.click_info:
click_info_button_mercury(self.debug)
yield # 4. Set and confirm group threshold
yield # 5. Set and confirm group threshold
self.debug.swipe_up()
yield # 5. Checklist
yield # 6. Checklist
self.debug.swipe_up(wait=True)
for _i in range(5): # for each of 5 groups
if self.click_info:
@ -1750,16 +1786,17 @@ class InputFlowSlip39AdvancedResetRecovery(InputFlowBase):
def input_flow_tt(self) -> BRGeneratorType:
# 1. Confirm Reset
# 2. Backup your seed
# 3. Confirm warning
# 4. shares info
# 5. Set & Confirm number of groups
# 6. threshold info
# 7. Set & confirm group threshold value
# 8-17: for each of 5 groups:
# 3. Backup intro
# 4. Confirm warning
# 5. shares info
# 6. Set & Confirm number of groups
# 7. threshold info
# 8. Set & confirm group threshold value
# 9-18: for each of 5 groups:
# 1. Set & Confirm number of shares
# 2. Set & confirm share threshold value
# 18. Confirm show seeds
yield from click_through(self.debug, screens=18, code=B.ResetDevice)
# 19. Confirm show seeds
yield from click_through(self.debug, screens=19, code=B.ResetDevice)
# Mnemonic phrases - show & confirm shares for all groups
self.mnemonics = yield from load_5_groups_5_shares(self.debug)
@ -1773,6 +1810,8 @@ class InputFlowSlip39AdvancedResetRecovery(InputFlowBase):
self.debug.press_yes()
yield # Wallet creation
self.debug.press_yes()
yield # Backup intro
self.debug.press_yes()
yield # Checklist
self.debug.press_yes()
yield # Set and confirm group count
@ -1804,17 +1843,19 @@ class InputFlowSlip39AdvancedResetRecovery(InputFlowBase):
def input_flow_t3t1(self) -> BRGeneratorType:
# 1. Confirm Reset
# 2. Backup your seed
# 3. Confirm warning
# 4. shares info
# 5. Set & Confirm number of groups
# 6. threshold info
# 7. Set & confirm group threshold value
# 8-17: for each of 5 groups:
# 2. Wallet Created
# 3. Prompt Backup
# 4. Backup intro
# 5. Confirm warning
# 6. shares info
# 7. Set & Confirm number of groups
# 8. threshold info
# 9. Set & confirm group threshold value
# 10-19: for each of 5 groups:
# 1. Set & Confirm number of shares
# 2. Set & confirm share threshold value
# 18. Confirm show seeds
yield from click_through(self.debug, screens=19, code=B.ResetDevice)
# 20. Confirm show seeds
yield from click_through(self.debug, screens=20, code=B.ResetDevice)
# Mnemonic phrases - show & confirm shares for all groups
self.mnemonics = yield from load_5_groups_5_shares(self.debug)