mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 23:08:14 +00:00
tests: add backup test for SLIP39 Basic
This commit is contained in:
parent
78ecc38b1b
commit
b30d9f6897
@ -16,16 +16,22 @@
|
||||
|
||||
|
||||
import pytest
|
||||
import shamir_mnemonic as shamir
|
||||
|
||||
from trezorlib import device, messages
|
||||
from trezorlib.messages import ButtonRequestType as B
|
||||
|
||||
from ..common import MNEMONIC12, read_and_confirm_mnemonic
|
||||
from ..common import (
|
||||
MNEMONIC12,
|
||||
MNEMONIC_SLIP39_BASIC_20_3of6,
|
||||
click_through,
|
||||
read_and_confirm_mnemonic,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip_t1 # TODO we want this for t1 too
|
||||
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
||||
def test_backup(client):
|
||||
def test_backup_bip39(client):
|
||||
assert client.features.needs_backup is True
|
||||
mnemonic = None
|
||||
|
||||
@ -54,3 +60,61 @@ def test_backup(client):
|
||||
device.backup(client)
|
||||
|
||||
assert mnemonic == MNEMONIC12
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
@pytest.mark.setup_client(mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6)
|
||||
def test_backup_slip39_basic(client):
|
||||
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)
|
||||
|
||||
# Mnemonic phrases
|
||||
for _ in range(5):
|
||||
yield # Phrase screen
|
||||
mnemonic = read_and_confirm_mnemonic(client.debug, words=20)
|
||||
mnemonics.append(mnemonic)
|
||||
yield # Confirm continue to next
|
||||
client.debug.press_yes()
|
||||
|
||||
# Confirm backup
|
||||
yield
|
||||
client.debug.press_yes()
|
||||
|
||||
with client:
|
||||
client.set_input_flow(input_flow)
|
||||
client.set_expected_responses(
|
||||
[
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.ResetDevice),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.ButtonRequest(code=B.Success),
|
||||
messages.Success(),
|
||||
]
|
||||
)
|
||||
device.backup(client)
|
||||
|
||||
expected_ms = shamir.combine_mnemonics(MNEMONIC_SLIP39_BASIC_20_3of6)
|
||||
actual_ms = shamir.combine_mnemonics(mnemonics[:3])
|
||||
assert expected_ms == actual_ms
|
||||
|
Loading…
Reference in New Issue
Block a user