|
|
|
@ -15,6 +15,7 @@
|
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
@ -25,6 +26,9 @@ from .. import buttons, common
|
|
|
|
|
from ..tx_cache import TxCache
|
|
|
|
|
from . import recovery
|
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from ..device_handler import BackgroundDeviceHandler
|
|
|
|
|
|
|
|
|
|
TX_CACHE = TxCache("Bitcoin")
|
|
|
|
|
|
|
|
|
|
TXHASH_d5f65e = bytes.fromhex(
|
|
|
|
@ -36,17 +40,20 @@ PIN4 = "1234"
|
|
|
|
|
WORDS_20 = buttons.grid34(2, 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_autolock_delay(device_handler, delay_ms):
|
|
|
|
|
def set_autolock_delay(device_handler: "BackgroundDeviceHandler", delay_ms: int):
|
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
|
|
|
|
|
|
device_handler.run(device.apply_settings, auto_lock_delay_ms=delay_ms)
|
|
|
|
|
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
|
assert layout.text == "PinDialog"
|
|
|
|
|
assert layout.text == "< PinKeyboard >"
|
|
|
|
|
debug.input("1234")
|
|
|
|
|
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
|
assert f"auto-lock your device after {delay_ms // 1000} seconds" in layout.text
|
|
|
|
|
assert (
|
|
|
|
|
f"auto-lock your device after {delay_ms // 1000} seconds"
|
|
|
|
|
in layout.get_content()
|
|
|
|
|
)
|
|
|
|
|
debug.click(buttons.OK)
|
|
|
|
|
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
@ -55,7 +62,7 @@ def set_autolock_delay(device_handler, delay_ms):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(pin=PIN4)
|
|
|
|
|
def test_autolock_interrupts_signing(device_handler):
|
|
|
|
|
def test_autolock_interrupts_signing(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
|
set_autolock_delay(device_handler, 10_000)
|
|
|
|
|
|
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
@ -76,10 +83,13 @@ def test_autolock_interrupts_signing(device_handler):
|
|
|
|
|
device_handler.run(btc.sign_tx, "Bitcoin", [inp1], [out1], prev_txes=TX_CACHE)
|
|
|
|
|
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
|
assert "1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1" in layout.text.replace(" ", "")
|
|
|
|
|
assert "1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1" in layout.get_content().replace(" ", "")
|
|
|
|
|
|
|
|
|
|
debug.click(buttons.OK, wait=True)
|
|
|
|
|
debug.click(buttons.OK, wait=True)
|
|
|
|
|
|
|
|
|
|
layout = debug.click(buttons.OK, wait=True)
|
|
|
|
|
assert "Total amount: 0.0039 BTC" in layout.text
|
|
|
|
|
assert "Total amount: 0.0039 BTC" in layout.get_content()
|
|
|
|
|
|
|
|
|
|
# wait for autolock to kick in
|
|
|
|
|
time.sleep(10.1)
|
|
|
|
@ -89,7 +99,7 @@ def test_autolock_interrupts_signing(device_handler):
|
|
|
|
|
|
|
|
|
|
@pytest.mark.xfail(reason="depends on #922")
|
|
|
|
|
@pytest.mark.setup_client(pin=PIN4, passphrase=True)
|
|
|
|
|
def test_autolock_passphrase_keyboard(device_handler):
|
|
|
|
|
def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
|
set_autolock_delay(device_handler, 10_000)
|
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
|
|
|
|
|
@ -109,7 +119,7 @@ def test_autolock_passphrase_keyboard(device_handler):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(pin=PIN4)
|
|
|
|
|
def test_dryrun_locks_at_number_of_words(device_handler):
|
|
|
|
|
def test_dryrun_locks_at_number_of_words(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
|
set_autolock_delay(device_handler, 10_000)
|
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
|
|
|
|
|
@ -117,11 +127,11 @@ def test_dryrun_locks_at_number_of_words(device_handler):
|
|
|
|
|
|
|
|
|
|
# unlock
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
|
assert "Do you really want to check the recovery seed?" in layout.text
|
|
|
|
|
assert "Do you really want to check the recovery seed?" in layout.get_content()
|
|
|
|
|
layout = debug.click(buttons.OK, wait=True)
|
|
|
|
|
assert layout.text == "PinDialog"
|
|
|
|
|
assert layout.text == "< PinKeyboard >"
|
|
|
|
|
layout = debug.input(PIN4, wait=True)
|
|
|
|
|
assert "Select number of words " in layout.text
|
|
|
|
|
assert "Select number of words " in layout.get_content()
|
|
|
|
|
|
|
|
|
|
# wait for autolock to trigger
|
|
|
|
|
time.sleep(10.1)
|
|
|
|
@ -132,15 +142,15 @@ def test_dryrun_locks_at_number_of_words(device_handler):
|
|
|
|
|
|
|
|
|
|
# unlock
|
|
|
|
|
layout = debug.click(buttons.OK, wait=True)
|
|
|
|
|
assert layout.text == "PinDialog"
|
|
|
|
|
assert layout.text == "< PinKeyboard >"
|
|
|
|
|
layout = debug.input(PIN4, wait=True)
|
|
|
|
|
|
|
|
|
|
# we are back at homescreen
|
|
|
|
|
assert "Select number of words" in layout.text
|
|
|
|
|
assert "Select number of words" in layout.get_content()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(pin=PIN4)
|
|
|
|
|
def test_dryrun_locks_at_word_entry(device_handler):
|
|
|
|
|
def test_dryrun_locks_at_word_entry(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
|
set_autolock_delay(device_handler, 10_000)
|
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
|
|
|
|
|
@ -148,9 +158,9 @@ def test_dryrun_locks_at_word_entry(device_handler):
|
|
|
|
|
|
|
|
|
|
# unlock
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
|
assert "Do you really want to check the recovery seed?" in layout.text
|
|
|
|
|
assert "Do you really want to check the recovery seed?" in layout.get_content()
|
|
|
|
|
layout = debug.click(buttons.OK, wait=True)
|
|
|
|
|
assert layout.text == "PinDialog"
|
|
|
|
|
assert layout.text == "< PinKeyboard >"
|
|
|
|
|
layout = debug.input(PIN4, wait=True)
|
|
|
|
|
|
|
|
|
|
# select 20 words
|
|
|
|
@ -158,7 +168,7 @@ def test_dryrun_locks_at_word_entry(device_handler):
|
|
|
|
|
|
|
|
|
|
layout = debug.click(buttons.OK, wait=True)
|
|
|
|
|
# make sure keyboard locks
|
|
|
|
|
assert layout.text == "Slip39Keyboard"
|
|
|
|
|
assert layout.text == "< MnemonicKeyboard >"
|
|
|
|
|
time.sleep(10.1)
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
|
assert layout.text == "Lockscreen"
|
|
|
|
@ -167,7 +177,7 @@ def test_dryrun_locks_at_word_entry(device_handler):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(pin=PIN4)
|
|
|
|
|
def test_dryrun_enter_word_slowly(device_handler):
|
|
|
|
|
def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
|
set_autolock_delay(device_handler, 10_000)
|
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
|
|
|
|
|
@ -175,9 +185,9 @@ def test_dryrun_enter_word_slowly(device_handler):
|
|
|
|
|
|
|
|
|
|
# unlock
|
|
|
|
|
layout = debug.wait_layout()
|
|
|
|
|
assert "Do you really want to check the recovery seed?" in layout.text
|
|
|
|
|
assert "Do you really want to check the recovery seed?" in layout.get_content()
|
|
|
|
|
layout = debug.click(buttons.OK, wait=True)
|
|
|
|
|
assert layout.text == "PinDialog"
|
|
|
|
|
assert layout.text == "< PinKeyboard >"
|
|
|
|
|
layout = debug.input(PIN4, wait=True)
|
|
|
|
|
|
|
|
|
|
# select 20 words
|
|
|
|
@ -185,11 +195,11 @@ def test_dryrun_enter_word_slowly(device_handler):
|
|
|
|
|
|
|
|
|
|
layout = debug.click(buttons.OK, wait=True)
|
|
|
|
|
# type the word OCEAN slowly
|
|
|
|
|
assert layout.text == "Slip39Keyboard"
|
|
|
|
|
for coords in buttons.type_word("ocea"):
|
|
|
|
|
assert layout.text == "< MnemonicKeyboard >"
|
|
|
|
|
for coords in buttons.type_word("ocea", is_slip39=True):
|
|
|
|
|
time.sleep(9)
|
|
|
|
|
debug.click(coords)
|
|
|
|
|
layout = debug.click(buttons.CONFIRM_WORD, wait=True)
|
|
|
|
|
# should not have locked, even though we took 9 seconds to type each letter
|
|
|
|
|
assert layout.text == "Slip39Keyboard"
|
|
|
|
|
assert layout.text == "< MnemonicKeyboard >"
|
|
|
|
|
device_handler.kill_task()
|
|
|
|
|