|
|
|
@ -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")
|
|
|
|
|