mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 17:42:02 +00:00
tests: improve Shamir persistence test
This commit is contained in:
parent
5488270bc3
commit
9b827baca0
@ -14,6 +14,8 @@
|
|||||||
# You should have received a copy of the License along with this library.
|
# 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>.
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from trezorlib import device
|
from trezorlib import device
|
||||||
|
|
||||||
from .. import buttons
|
from .. import buttons
|
||||||
@ -29,42 +31,42 @@ def enter_word(debug, word):
|
|||||||
return debug.click(buttons.CONFIRM_WORD, wait=True)
|
return debug.click(buttons.CONFIRM_WORD, wait=True)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def emulator():
|
||||||
|
emu = EmulatorWrapper("core")
|
||||||
|
with emu:
|
||||||
|
yield emu
|
||||||
|
|
||||||
|
|
||||||
@core_only
|
@core_only
|
||||||
def test_persistence():
|
def test_persistence(emulator):
|
||||||
with EmulatorWrapper("core") as emu, BackgroundDeviceHandler(
|
device_handler = BackgroundDeviceHandler(emulator.client)
|
||||||
emu.client
|
debug = device_handler.debuglink()
|
||||||
) as device_handler:
|
features = device_handler.features()
|
||||||
debug = device_handler.debuglink()
|
|
||||||
features = device_handler.features()
|
|
||||||
|
|
||||||
assert features.recovery_mode is False
|
assert features.recovery_mode is False
|
||||||
|
|
||||||
device_handler.run(device.recover, pin_protection=False)
|
device_handler.run(device.recover, pin_protection=False)
|
||||||
layout = debug.wait_layout()
|
layout = debug.wait_layout()
|
||||||
assert layout.text.startswith("Recovery mode")
|
assert layout.text.startswith("Recovery mode")
|
||||||
|
|
||||||
layout = debug.click(buttons.OK, wait=True)
|
layout = debug.click(buttons.OK, wait=True)
|
||||||
assert "Select number of words" in layout.text
|
assert "Select number of words" in layout.text
|
||||||
|
|
||||||
storage = emu.storage()
|
device_handler.restart(emulator)
|
||||||
device_handler.kill_task()
|
debug = device_handler.debuglink()
|
||||||
|
features = device_handler.features()
|
||||||
|
|
||||||
with EmulatorWrapper("core", storage=storage) as emu, BackgroundDeviceHandler(
|
assert features.recovery_mode is True
|
||||||
emu.client
|
|
||||||
) as device_handler:
|
|
||||||
debug = device_handler.debuglink()
|
|
||||||
features = device_handler.features()
|
|
||||||
|
|
||||||
assert features.recovery_mode is True
|
# 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)
|
||||||
|
|
||||||
# no waiting for layout because layout doesn't change
|
assert layout.text.startswith("Abort recovery")
|
||||||
layout = debug.read_layout()
|
layout = debug.click(buttons.OK, wait=True)
|
||||||
assert "Select number of words" in layout.text
|
|
||||||
layout = debug.click(buttons.CANCEL, wait=True)
|
|
||||||
|
|
||||||
assert layout.text.startswith("Abort recovery")
|
assert layout.text == "Homescreen"
|
||||||
layout = debug.click(buttons.OK, wait=True)
|
features = device_handler.features()
|
||||||
|
assert features.recovery_mode is False
|
||||||
assert layout.text == "Homescreen"
|
|
||||||
features = device_handler.features()
|
|
||||||
assert features.recovery_mode is False
|
|
||||||
|
Loading…
Reference in New Issue
Block a user