1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-25 15:58:08 +00:00

tests: add upgrade test for recovery

This commit is contained in:
Tomas Susanka 2019-10-25 14:37:35 +00:00
parent ab59b4731a
commit 04f0b74b29
3 changed files with 52 additions and 2 deletions

View File

@ -24,6 +24,7 @@ MNEMONIC_SLIP39_BASIC_20_3of6 = [
"extra extend academic acne away best indicate impact square oasis prospect painting voting guest either argue username racism enemy eclipse",
"extra extend academic arcade born dive legal hush gross briefing talent drug much home firefly toxic analysis idea umbrella slice",
]
MNEMONIC_SLIP39_BASIC_20_3of6_SECRET = "491b795b80fc21ccdf466c0fbc98c8fc"
# Shamir shares (128 bits, 2 groups from 1 of 1, 1 of 1, 3 of 5, 2 of 6)
MNEMONIC_SLIP39_ADVANCED_20 = [
"eraser senior beard romp adorn nuclear spill corner cradle style ancient family general leader ambition exchange unusual garlic promise voice",

View File

@ -18,7 +18,11 @@ import pytest
from trezorlib import device, exceptions, messages
from ..common import MNEMONIC_SLIP39_BASIC_20_3of6, recovery_enter_shares
from ..common import (
MNEMONIC_SLIP39_BASIC_20_3of6,
MNEMONIC_SLIP39_BASIC_20_3of6_SECRET,
recovery_enter_shares,
)
pytestmark = pytest.mark.skip_t1
@ -33,7 +37,7 @@ MNEMONIC_SLIP39_BASIC_33_2of5 = [
]
VECTORS = (
(MNEMONIC_SLIP39_BASIC_20_3of6, "491b795b80fc21ccdf466c0fbc98c8fc"),
(MNEMONIC_SLIP39_BASIC_20_3of6, MNEMONIC_SLIP39_BASIC_20_3of6_SECRET),
(
MNEMONIC_SLIP39_BASIC_33_2of5,
"b770e0da1363247652de97a39bdbf2463be087848d709ecbf28e84508e31202a",

View File

@ -17,8 +17,12 @@
import pytest
from trezorlib import MINIMUM_FIRMWARE_VERSION, btc, debuglink, device
from trezorlib.messages import BackupType
from trezorlib.tools import H_
from ..click_tests import recovery
from ..common import MNEMONIC_SLIP39_BASIC_20_3of6, MNEMONIC_SLIP39_BASIC_20_3of6_SECRET
from ..device_handler import BackgroundDeviceHandler
from ..emulators import ALL_TAGS, EmulatorWrapper
from . import SELECTED_GENS
@ -194,6 +198,47 @@ def test_upgrade_reset_no_backup(gen, from_tag, to_tag):
assert btc.get_address(emu.client, "Bitcoin", PATH) == address
# Although Shamir was introduced in 2.1.2 already, the debug instrumentation was not present until 2.1.9.
@for_all("core", minimum_version=(2, 1, 9))
def test_upgrade_shamir_recovery(gen, from_tag, to_tag):
with EmulatorWrapper(gen, from_tag) as emu, BackgroundDeviceHandler(
emu.client
) as device_handler:
assert emu.client.features.recovery_mode is False
debug = device_handler.debuglink()
device_handler.run(device.recover, pin_protection=False)
recovery.select_number_of_words(debug)
layout = recovery.enter_share(debug, MNEMONIC_SLIP39_BASIC_20_3of6[0])
assert "2 more shares" in layout.text
device_id = emu.client.features.device_id
storage = emu.storage()
device_handler.check_finalize()
with EmulatorWrapper(gen, to_tag, storage=storage) as emu, BackgroundDeviceHandler(
emu.client
) as device_handler:
assert device_id == emu.client.features.device_id
assert emu.client.features.recovery_mode
debug = device_handler.debuglink()
# second share
layout = recovery.enter_share(debug, MNEMONIC_SLIP39_BASIC_20_3of6[2])
assert "1 more share" in layout.text
# last one
layout = recovery.enter_share(debug, MNEMONIC_SLIP39_BASIC_20_3of6[1])
assert "You have successfully" in layout.text
# Check the result
state = debug.state()
assert state.mnemonic_secret.hex() == MNEMONIC_SLIP39_BASIC_20_3of6_SECRET
assert state.mnemonic_type == BackupType.Slip39_Basic
device_handler.check_finalize()
if __name__ == "__main__":
if not ALL_TAGS:
print("No versions found. Remember to run download_emulators.sh")