mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-17 21:22:10 +00:00
feat(tests): clicking Info button in (Super)Shamir backup device tests
This commit is contained in:
parent
5c4703c9bb
commit
e4b5f10223
@ -18,6 +18,7 @@ BOTTOM = grid(DISPLAY_HEIGHT, 4, 3)
|
||||
OK = (RIGHT, BOTTOM)
|
||||
CANCEL = (LEFT, BOTTOM)
|
||||
INFO = (MID, BOTTOM)
|
||||
INFO_SHAMIR_RECOVERY = (LEFT, BOTTOM)
|
||||
|
||||
CONFIRM_WORD = (MID, TOP)
|
||||
|
||||
|
@ -22,6 +22,8 @@ import pytest
|
||||
from trezorlib import btc, tools
|
||||
from trezorlib.messages import ButtonRequestType as B
|
||||
|
||||
from .buttons import INFO
|
||||
|
||||
# fmt: off
|
||||
# 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
MNEMONIC12 = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle"
|
||||
@ -155,9 +157,8 @@ def recovery_enter_shares(debug, shares, groups=False, click_info=False):
|
||||
|
||||
if click_info:
|
||||
# Moving through the INFO button
|
||||
info_button = (120, 220)
|
||||
debug.wait_layout()
|
||||
debug.click(info_button)
|
||||
debug.click(INFO)
|
||||
yield
|
||||
debug.wait_layout()
|
||||
debug.swipe_up()
|
||||
|
@ -22,15 +22,25 @@ from trezorlib import device, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.messages import ButtonRequestType as B
|
||||
|
||||
from ..buttons import INFO_SHAMIR_RECOVERY
|
||||
from ..common import (
|
||||
MNEMONIC12,
|
||||
MNEMONIC_SLIP39_ADVANCED_20,
|
||||
MNEMONIC_SLIP39_BASIC_20_3of6,
|
||||
click_through,
|
||||
read_and_confirm_mnemonic,
|
||||
)
|
||||
|
||||
|
||||
def click_info_button(debug):
|
||||
"""Click Shamir backup info button and return back."""
|
||||
debug.wait_layout()
|
||||
debug.click(INFO_SHAMIR_RECOVERY)
|
||||
yield # Info screen with text
|
||||
# Confirming the info message, press_yes() did not work
|
||||
debug.wait_layout()
|
||||
debug.click(INFO_SHAMIR_RECOVERY)
|
||||
|
||||
|
||||
@pytest.mark.skip_t1 # TODO we want this for t1 too
|
||||
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC12)
|
||||
def test_backup_bip39(client):
|
||||
@ -73,18 +83,30 @@ def test_backup_bip39(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6)
|
||||
def test_backup_slip39_basic(client):
|
||||
@pytest.mark.parametrize(
|
||||
"click_info", [True, False], ids=["click_info", "no_click_info"]
|
||||
)
|
||||
def test_backup_slip39_basic(client, click_info: bool):
|
||||
assert client.features.needs_backup is True
|
||||
mnemonics = []
|
||||
|
||||
def input_flow():
|
||||
# 1. Checklist
|
||||
# 2. Number of shares (5)
|
||||
# 3. Checklist
|
||||
# 4. Threshold (3)
|
||||
# 5. Checklist
|
||||
# 6. Confirm show seeds
|
||||
yield from click_through(client.debug, screens=6, code=B.ResetDevice)
|
||||
yield # Checklist
|
||||
client.debug.press_yes()
|
||||
if click_info:
|
||||
yield from click_info_button(client.debug)
|
||||
yield # Number of shares (5)
|
||||
client.debug.press_yes()
|
||||
yield # Checklist
|
||||
client.debug.press_yes()
|
||||
if click_info:
|
||||
yield from click_info_button(client.debug)
|
||||
yield # Threshold (3)
|
||||
client.debug.press_yes()
|
||||
yield # Checklist
|
||||
client.debug.press_yes()
|
||||
yield # Confirm show seeds
|
||||
client.debug.press_yes()
|
||||
|
||||
# Mnemonic phrases
|
||||
for _ in range(5):
|
||||
@ -94,14 +116,16 @@ def test_backup_slip39_basic(client):
|
||||
yield # Confirm continue to next
|
||||
client.debug.press_yes()
|
||||
|
||||
# Confirm backup
|
||||
yield
|
||||
yield # Confirm backup
|
||||
client.debug.press_yes()
|
||||
|
||||
with client:
|
||||
if click_info:
|
||||
client.watch_layout()
|
||||
client.set_input_flow(input_flow)
|
||||
client.set_expected_responses(
|
||||
[messages.ButtonRequest(code=B.ResetDevice)] * 6 # intro screens
|
||||
[messages.ButtonRequest(code=B.ResetDevice)]
|
||||
* (8 if click_info else 6) # intro screens (and optional info)
|
||||
+ [
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
@ -129,21 +153,39 @@ def test_backup_slip39_basic(client):
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC_SLIP39_ADVANCED_20)
|
||||
def test_backup_slip39_advanced(client):
|
||||
@pytest.mark.parametrize(
|
||||
"click_info", [True, False], ids=["click_info", "no_click_info"]
|
||||
)
|
||||
def test_backup_slip39_advanced(client, click_info: bool):
|
||||
assert client.features.needs_backup is True
|
||||
mnemonics = []
|
||||
|
||||
def input_flow():
|
||||
# 1. Checklist
|
||||
# 2. Set and confirm group count
|
||||
# 3. Checklist
|
||||
# 4. Set and confirm group threshold
|
||||
# 5. Checklist
|
||||
# 6-15: for each of 5 groups:
|
||||
# 1. Set & Confirm number of shares
|
||||
# 2. Set & confirm share threshold value
|
||||
# 16. Confirm show seeds
|
||||
yield from click_through(client.debug, screens=16, code=B.ResetDevice)
|
||||
yield # Checklist
|
||||
client.debug.press_yes()
|
||||
if click_info:
|
||||
yield from click_info_button(client.debug)
|
||||
yield # Set and confirm group count
|
||||
client.debug.press_yes()
|
||||
yield # Checklist
|
||||
client.debug.press_yes()
|
||||
if click_info:
|
||||
yield from click_info_button(client.debug)
|
||||
yield # Set and confirm group threshold
|
||||
client.debug.press_yes()
|
||||
yield # Checklist
|
||||
client.debug.press_yes()
|
||||
for _ in range(5): # for each of 5 groups
|
||||
if click_info:
|
||||
yield from click_info_button(client.debug)
|
||||
yield # Set & Confirm number of shares
|
||||
client.debug.press_yes()
|
||||
if click_info:
|
||||
yield from click_info_button(client.debug)
|
||||
yield # Set & confirm share threshold value
|
||||
client.debug.press_yes()
|
||||
yield # Confirm show seeds
|
||||
client.debug.press_yes()
|
||||
|
||||
# Mnemonic phrases
|
||||
for _ in range(5):
|
||||
@ -154,19 +196,23 @@ def test_backup_slip39_advanced(client):
|
||||
yield # Confirm continue to next
|
||||
client.debug.press_yes()
|
||||
|
||||
# Confirm backup
|
||||
yield
|
||||
yield # Confirm backup
|
||||
client.debug.press_yes()
|
||||
|
||||
with client:
|
||||
if click_info:
|
||||
client.watch_layout()
|
||||
client.set_input_flow(input_flow)
|
||||
client.set_expected_responses(
|
||||
[messages.ButtonRequest(code=B.ResetDevice)] * 6 # intro screens
|
||||
[messages.ButtonRequest(code=B.ResetDevice)]
|
||||
* (8 if click_info else 6) # intro screens (and optional info)
|
||||
+ [
|
||||
(click_info, messages.ButtonRequest(code=B.ResetDevice)),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
(click_info, messages.ButtonRequest(code=B.ResetDevice)),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
]
|
||||
* 5 # group thresholds
|
||||
* 5 # group thresholds (and optional info)
|
||||
+ [
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
|
@ -840,8 +840,10 @@
|
||||
"test_msg_applysettings.py::test_label_too_long": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1",
|
||||
"test_msg_applysettings.py::test_safety_checks": "71ac970ca0d87f1ef70a8605dcc4db478a9190333307ff37ee90dd3d3e97e0fa",
|
||||
"test_msg_backup_device.py::test_backup_bip39": "9b572b12da20b516222ecb0a76fba6d6de5193647405b67625140ed3ed45049c",
|
||||
"test_msg_backup_device.py::test_backup_slip39_advanced": "ff2ffe2c93d8784566e2ac9516f8fd41f4f7e45e1272aff6d3313bdca173e6e2",
|
||||
"test_msg_backup_device.py::test_backup_slip39_basic": "fe7ef8726326e2702ee680418d8a32cf2e0d062accbc70acbe88abd86cbf9f6d",
|
||||
"test_msg_backup_device.py::test_backup_slip39_advanced[click_info]": "109ca7d22aec0f47fdee5ce22db4ef3670ee783bab31abc5666f076c96126e26",
|
||||
"test_msg_backup_device.py::test_backup_slip39_advanced[no_click_info]": "ff2ffe2c93d8784566e2ac9516f8fd41f4f7e45e1272aff6d3313bdca173e6e2",
|
||||
"test_msg_backup_device.py::test_backup_slip39_basic[click_info]": "41f8beb6c0837ceae3d693e9fe900aec6b6d7917ef13d59763bbd6d7f147ff52",
|
||||
"test_msg_backup_device.py::test_backup_slip39_basic[no_click_info]": "fe7ef8726326e2702ee680418d8a32cf2e0d062accbc70acbe88abd86cbf9f6d",
|
||||
"test_msg_backup_device.py::test_interrupt_backup_fails": "75ab647310ba48b46e161de8204590807f04490e60a4f664749433016b9f5ff4",
|
||||
"test_msg_backup_device.py::test_no_backup_fails": "a489388c56078b4aa243d991b898b196a5c4b05573c526db06eeb11d41e98ec8",
|
||||
"test_msg_backup_device.py::test_no_backup_show_entropy_fails": "836598efda5b456ccbee7835e31892bfb5a8b9d9e42948982f444e10b9b8e55a",
|
||||
|
Loading…
Reference in New Issue
Block a user