mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
chore(tests): update persistence tests
This commit is contained in:
parent
00b83d1dca
commit
0dd3098aeb
@ -41,11 +41,11 @@ def test_abort(core_emulator: Emulator):
|
|||||||
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()
|
|
||||||
assert layout.get_title() == "WALLET RECOVERY"
|
assert debug.wait_layout().title() == "WALLET RECOVERY"
|
||||||
|
|
||||||
layout = debug.click(buttons.OK, wait=True)
|
layout = debug.click(buttons.OK, wait=True)
|
||||||
assert "Select number of words" in layout.get_content()
|
assert "select the number of words" in layout.text_content()
|
||||||
|
|
||||||
debug = _restart(device_handler, core_emulator)
|
debug = _restart(device_handler, core_emulator)
|
||||||
features = device_handler.features()
|
features = device_handler.features()
|
||||||
@ -53,14 +53,13 @@ def test_abort(core_emulator: Emulator):
|
|||||||
assert features.recovery_mode is True
|
assert features.recovery_mode is True
|
||||||
|
|
||||||
# no waiting for layout because layout doesn't change
|
# no waiting for layout because layout doesn't change
|
||||||
layout = debug.read_layout()
|
assert "select the number of words" in debug.read_layout().text_content()
|
||||||
assert "Select number of words" in layout.get_content()
|
|
||||||
layout = debug.click(buttons.CANCEL, wait=True)
|
layout = debug.click(buttons.CANCEL, wait=True)
|
||||||
|
|
||||||
assert layout.get_title() == "ABORT RECOVERY"
|
assert layout.title() == "ABORT RECOVERY"
|
||||||
layout = debug.click(buttons.OK, wait=True)
|
layout = debug.click(buttons.OK, wait=True)
|
||||||
|
|
||||||
assert layout.text.startswith("< Homescreen")
|
assert layout.main_component() == "Homescreen"
|
||||||
features = device_handler.features()
|
features = device_handler.features()
|
||||||
assert features.recovery_mode is False
|
assert features.recovery_mode is False
|
||||||
|
|
||||||
@ -75,6 +74,7 @@ def test_recovery_single_reset(core_emulator: Emulator):
|
|||||||
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)
|
||||||
|
|
||||||
recovery.confirm_recovery(debug)
|
recovery.confirm_recovery(debug)
|
||||||
|
|
||||||
recovery.select_number_of_words(debug)
|
recovery.select_number_of_words(debug)
|
||||||
@ -112,6 +112,7 @@ def test_recovery_on_old_wallet(core_emulator: Emulator):
|
|||||||
|
|
||||||
# enter recovery mode
|
# enter recovery mode
|
||||||
device_handler.run(device.recover, pin_protection=False)
|
device_handler.run(device.recover, pin_protection=False)
|
||||||
|
|
||||||
recovery.confirm_recovery(debug)
|
recovery.confirm_recovery(debug)
|
||||||
|
|
||||||
# restart to get into stand-alone recovery
|
# restart to get into stand-alone recovery
|
||||||
@ -126,11 +127,9 @@ def test_recovery_on_old_wallet(core_emulator: Emulator):
|
|||||||
words = first_share.split(" ")
|
words = first_share.split(" ")
|
||||||
|
|
||||||
# start entering first share
|
# start entering first share
|
||||||
layout = debug.read_layout()
|
assert "Enter any share" in debug.read_layout().text_content()
|
||||||
assert "Enter any share" in layout.text
|
|
||||||
debug.press_yes()
|
debug.press_yes()
|
||||||
layout = debug.wait_layout()
|
assert debug.wait_layout().main_component() == "MnemonicKeyboard"
|
||||||
assert layout.text == "< MnemonicKeyboard >"
|
|
||||||
|
|
||||||
# enter first word
|
# enter first word
|
||||||
debug.input(words[0])
|
debug.input(words[0])
|
||||||
@ -142,12 +141,12 @@ def test_recovery_on_old_wallet(core_emulator: Emulator):
|
|||||||
|
|
||||||
# try entering remaining 19 words
|
# try entering remaining 19 words
|
||||||
for word in words[1:]:
|
for word in words[1:]:
|
||||||
assert layout.text == "< MnemonicKeyboard >"
|
assert layout.main_component() == "MnemonicKeyboard"
|
||||||
debug.input(word)
|
debug.input(word)
|
||||||
layout = debug.wait_layout()
|
layout = debug.wait_layout()
|
||||||
|
|
||||||
# check that we entered the first share successfully
|
# check that we entered the first share successfully
|
||||||
assert "2 more shares" in layout.text
|
assert "2 more shares" in layout.text_content()
|
||||||
|
|
||||||
# try entering the remaining shares
|
# try entering the remaining shares
|
||||||
for share in MNEMONIC_SLIP39_BASIC_20_3of6[1:3]:
|
for share in MNEMONIC_SLIP39_BASIC_20_3of6[1:3]:
|
||||||
@ -169,13 +168,13 @@ def test_recovery_multiple_resets(core_emulator: Emulator):
|
|||||||
expected_text = "Enter any share"
|
expected_text = "Enter any share"
|
||||||
remaining = len(shares)
|
remaining = len(shares)
|
||||||
for share in shares:
|
for share in shares:
|
||||||
assert expected_text in layout.text
|
assert expected_text in layout.text_content()
|
||||||
layout = recovery.enter_share(debug, share)
|
layout = recovery.enter_share(debug, share)
|
||||||
remaining -= 1
|
remaining -= 1
|
||||||
expected_text = "You have entered"
|
expected_text = "You have entered"
|
||||||
debug = _restart(device_handler, core_emulator)
|
debug = _restart(device_handler, core_emulator)
|
||||||
|
|
||||||
assert "You have successfully recovered your wallet" in layout.get_content()
|
assert "You have finished recovering your wallet" in layout.text_content()
|
||||||
|
|
||||||
device_handler = BackgroundDeviceHandler(core_emulator.client)
|
device_handler = BackgroundDeviceHandler(core_emulator.client)
|
||||||
debug = device_handler.debuglink()
|
debug = device_handler.debuglink()
|
||||||
@ -186,6 +185,7 @@ def test_recovery_multiple_resets(core_emulator: Emulator):
|
|||||||
|
|
||||||
# start device and recovery
|
# start device and recovery
|
||||||
device_handler.run(device.recover, pin_protection=False)
|
device_handler.run(device.recover, pin_protection=False)
|
||||||
|
|
||||||
recovery.confirm_recovery(debug)
|
recovery.confirm_recovery(debug)
|
||||||
|
|
||||||
# set number of words
|
# set number of words
|
||||||
@ -202,8 +202,7 @@ def test_recovery_multiple_resets(core_emulator: Emulator):
|
|||||||
# enter shares and restart after each one
|
# enter shares and restart after each one
|
||||||
enter_shares_with_restarts(debug)
|
enter_shares_with_restarts(debug)
|
||||||
debug = device_handler.debuglink()
|
debug = device_handler.debuglink()
|
||||||
layout = debug.read_layout()
|
assert debug.read_layout().main_component() == "Homescreen"
|
||||||
assert layout.text.startswith("< Homescreen")
|
|
||||||
|
|
||||||
features = device_handler.features()
|
features = device_handler.features()
|
||||||
assert features.initialized is True
|
assert features.initialized is True
|
||||||
|
@ -3,6 +3,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client
|
|||||||
|
|
||||||
from ..common import MNEMONIC12
|
from ..common import MNEMONIC12
|
||||||
from ..emulators import Emulator, EmulatorWrapper
|
from ..emulators import Emulator, EmulatorWrapper
|
||||||
|
from ..input_flows import InputFlowSetupDevicePINWIpeCode
|
||||||
from ..upgrade_tests import core_only, legacy_only
|
from ..upgrade_tests import core_only, legacy_only
|
||||||
|
|
||||||
PIN = "1234"
|
PIN = "1234"
|
||||||
@ -26,24 +27,9 @@ def setup_device_core(client: Client, pin: str, wipe_code: str) -> None:
|
|||||||
client, MNEMONIC12, pin, passphrase_protection=False, label="WIPECODE"
|
client, MNEMONIC12, pin, passphrase_protection=False, label="WIPECODE"
|
||||||
)
|
)
|
||||||
|
|
||||||
def input_flow():
|
|
||||||
yield # do you want to set/change the wipe_code?
|
|
||||||
client.debug.press_yes()
|
|
||||||
if pin is not None:
|
|
||||||
yield # enter current pin
|
|
||||||
client.debug.input(pin)
|
|
||||||
yield # enter new wipe code
|
|
||||||
client.debug.input(wipe_code)
|
|
||||||
yield # enter new wipe code again
|
|
||||||
client.debug.input(wipe_code)
|
|
||||||
yield # success
|
|
||||||
client.debug.press_yes()
|
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(
|
IF = InputFlowSetupDevicePINWIpeCode(client, pin, wipe_code)
|
||||||
[messages.ButtonRequest()] * 5 + [messages.Success, messages.Features]
|
client.set_input_flow(IF.get())
|
||||||
)
|
|
||||||
client.set_input_flow(input_flow)
|
|
||||||
device.change_wipe_code(client)
|
device.change_wipe_code(client)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user