You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.2 KiB
73 lines
2.2 KiB
5 years ago
|
# This file is part of the Trezor project.
|
||
|
#
|
||
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
||
|
#
|
||
|
# This library is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU Lesser General Public License version 3
|
||
|
# as published by the Free Software Foundation.
|
||
|
#
|
||
|
# This library is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU Lesser General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the License along with this library.
|
||
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||
|
|
||
5 years ago
|
import pytest
|
||
|
|
||
5 years ago
|
from trezorlib import device
|
||
|
|
||
|
from .. import buttons
|
||
|
from ..device_handler import BackgroundDeviceHandler
|
||
|
from ..emulators import EmulatorWrapper
|
||
5 years ago
|
from ..upgrade_tests import core_only
|
||
5 years ago
|
|
||
|
|
||
|
def enter_word(debug, word):
|
||
|
word = word[:4]
|
||
|
for coords in buttons.type_word(word):
|
||
|
debug.click(coords)
|
||
|
return debug.click(buttons.CONFIRM_WORD, wait=True)
|
||
|
|
||
|
|
||
5 years ago
|
@pytest.fixture
|
||
|
def emulator():
|
||
|
emu = EmulatorWrapper("core")
|
||
|
with emu:
|
||
|
yield emu
|
||
5 years ago
|
|
||
|
|
||
5 years ago
|
@core_only
|
||
|
def test_persistence(emulator):
|
||
|
device_handler = BackgroundDeviceHandler(emulator.client)
|
||
|
debug = device_handler.debuglink()
|
||
|
features = device_handler.features()
|
||
|
|
||
|
assert features.recovery_mode is False
|
||
5 years ago
|
|
||
5 years ago
|
device_handler.run(device.recover, pin_protection=False)
|
||
|
layout = debug.wait_layout()
|
||
|
assert layout.text.startswith("Recovery mode")
|
||
5 years ago
|
|
||
5 years ago
|
layout = debug.click(buttons.OK, wait=True)
|
||
|
assert "Select number of words" in layout.text
|
||
5 years ago
|
|
||
5 years ago
|
device_handler.restart(emulator)
|
||
|
debug = device_handler.debuglink()
|
||
|
features = device_handler.features()
|
||
5 years ago
|
|
||
5 years ago
|
assert features.recovery_mode is True
|
||
5 years ago
|
|
||
5 years ago
|
# no waiting for layout because layout doesn't change
|
||
|
layout = debug.read_layout()
|
||
|
assert "Select number of words" in layout.text
|
||
|
layout = debug.click(buttons.CANCEL, wait=True)
|
||
5 years ago
|
|
||
5 years ago
|
assert layout.text.startswith("Abort recovery")
|
||
|
layout = debug.click(buttons.OK, wait=True)
|
||
5 years ago
|
|
||
5 years ago
|
assert layout.text == "Homescreen"
|
||
|
features = device_handler.features()
|
||
|
assert features.recovery_mode is False
|