1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

feat(tests): SuperShamir device tests for clicking Info button

This commit is contained in:
grdddj 2021-12-01 14:21:12 +01:00 committed by matejcik
parent 4419572437
commit 6c8e6dcc08
3 changed files with 39 additions and 27 deletions

View File

@ -113,7 +113,7 @@ def generate_entropy(strength, internal_entropy, external_entropy):
return entropy_stripped
def recovery_enter_shares(debug, shares, groups=False):
def recovery_enter_shares(debug, shares, groups=False, click_info=False):
"""Perform the recovery flow for a set of Shamir shares.
For use in an input flow function.
@ -152,6 +152,18 @@ def recovery_enter_shares(debug, shares, groups=False):
# Homescreen - continue
# or Homescreen - confirm success
yield
if click_info:
# Moving through the INFO button
info_button = (120, 220)
debug.wait_layout()
debug.click(info_button)
yield
debug.wait_layout()
debug.swipe_up()
debug.press_yes()
# Finishing with current share
debug.press_yes()

View File

@ -40,18 +40,21 @@ VECTORS = (
)
@pytest.mark.parametrize("shares, secret", VECTORS)
@pytest.mark.setup_client(uninitialized=True)
def test_secret(client, shares, secret):
# To allow reusing functionality for multiple tests
def _test_secret(client, shares, secret, click_info=False):
debug = client.debug
def input_flow():
yield # Confirm Recovery
debug.press_yes()
# Proceed with recovery
yield from recovery_enter_shares(debug, shares, groups=True)
yield from recovery_enter_shares(
debug, shares, groups=True, click_info=click_info
)
with client:
if click_info:
client.watch_layout()
client.set_input_flow(input_flow)
ret = device.recover(
client, pin_protection=False, passphrase_protection=False, label="label"
@ -66,30 +69,25 @@ def test_secret(client, shares, secret):
assert debug.state().mnemonic_secret.hex() == secret
@pytest.mark.parametrize("shares, secret", VECTORS)
@pytest.mark.setup_client(uninitialized=True)
def test_secret(client, shares, secret):
_test_secret(client, shares, secret)
@pytest.mark.parametrize("shares, secret", VECTORS)
@pytest.mark.setup_client(uninitialized=True)
def test_secret_click_info_button(client, shares, secret):
_test_secret(client, shares, secret, click_info=True)
@pytest.mark.setup_client(uninitialized=True)
def test_extra_share_entered(client):
debug = client.debug
def input_flow():
yield # Confirm Recovery
debug.press_yes()
# Proceed with recovery
yield from recovery_enter_shares(
debug, EXTRA_GROUP_SHARE + MNEMONIC_SLIP39_ADVANCED_20, groups=True
)
with client:
client.set_input_flow(input_flow)
ret = device.recover(
client, pin_protection=False, passphrase_protection=False, label="label"
)
# Workflow succesfully ended
assert ret == messages.Success(message="Device recovered")
assert client.features.initialized is True
assert client.features.pin_protection is False
assert client.features.passphrase_protection is False
assert client.features.backup_type is messages.BackupType.Slip39_Advanced
_test_secret(
client,
shares=EXTRA_GROUP_SHARE + MNEMONIC_SLIP39_ADVANCED_20,
secret=VECTORS[0][1],
)
@pytest.mark.setup_client(uninitialized=True)

View File

@ -516,6 +516,8 @@
"test_msg_recoverydevice_slip39_advanced.py::test_same_share": "9beff3d0bd3846fdb8a6539277a2ed07b3ada9e89211d78d5e976a36d70edd09",
"test_msg_recoverydevice_slip39_advanced.py::test_secret[shares0-c2d2e26ad06023c60145f150abe2dd2b]": "f8ce0cbe8cc57f105c1871ad57e62deba75051a8952989010c32bc69cc2f58a0",
"test_msg_recoverydevice_slip39_advanced.py::test_secret[shares1-c41d5cf80fed71a008a3a0ae045-c5b70566": "8e7410fd4e2cf20530ea079588ef61829a7948a1aa12e3776cbbd19153516151",
"test_msg_recoverydevice_slip39_advanced.py::test_secret_click_info_button[shares0-c2d2e26ad-038f73e5": "61f31fe7298aee6be9dbdfe6d3316d96b980b1796f505dd1f85216676c1c3733",
"test_msg_recoverydevice_slip39_advanced.py::test_secret_click_info_button[shares1-c41d5cf80-ac77a32f": "7b6537c008092c5875d551fb83d52af3227e1149ecb15c4e8a9095e3e95ca26f",
"test_msg_recoverydevice_slip39_advanced_dryrun.py::test_2of3_dryrun": "09e5dc650f1d95ee75cb1d6c50460da9865900b2991c4b04e027c4c40d0e39d0",
"test_msg_recoverydevice_slip39_advanced_dryrun.py::test_2of3_invalid_seed_dryrun": "282b18ab25bc393493355b6a51959a5cfc221cda87ec64985a634630177a02a1",
"test_msg_recoverydevice_slip39_basic.py::test_1of1": "65c8af9357e1e499cd17246100415bbcae7646a11d2b6381b88961b1b19e87a9",