mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-14 03:30:02 +00:00
feat(core/debug): better ButtonAck deadlock detection
This commit is contained in:
parent
4e8fb737d8
commit
a0267004d5
@ -4,6 +4,7 @@ if not __debug__:
|
||||
halt("debug mode inactive")
|
||||
|
||||
if __debug__:
|
||||
from micropython import const
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import trezorui2
|
||||
@ -37,7 +38,9 @@ if __debug__:
|
||||
|
||||
REFRESH_INDEX = 0
|
||||
|
||||
_DEADLOCK_DETECT_SLEEP = loop.sleep(2000)
|
||||
_DEADLOCK_WAIT_TRIES = const(5)
|
||||
_DEADLOCK_SLEEP_MS = const(2000)
|
||||
_DEADLOCK_DETECT_SLEEP = loop.sleep(_DEADLOCK_SLEEP_MS)
|
||||
|
||||
def screenshot() -> bool:
|
||||
if storage.save_screen:
|
||||
@ -52,8 +55,14 @@ if __debug__:
|
||||
def notify_layout_change(layout: Layout | None) -> None:
|
||||
layout_change_chan.put(layout, replace=True)
|
||||
|
||||
def wait_until_layout_is_running() -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
def wait_until_layout_is_running(tries: int | None = _DEADLOCK_WAIT_TRIES) -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
counter = 0
|
||||
while ui.CURRENT_LAYOUT is None:
|
||||
counter += 1
|
||||
if tries is not None and counter > tries:
|
||||
raise wire.FirmwareError(
|
||||
"layout deadlock detected (did you send a ButtonAck?)"
|
||||
)
|
||||
yield
|
||||
|
||||
async def return_layout_change(
|
||||
|
@ -1031,22 +1031,7 @@ class InputFlowSignTxInformationReplacement(InputFlowBase):
|
||||
self.debug.press_right()
|
||||
self.debug.press_right()
|
||||
|
||||
def input_flow_t3t1(self) -> BRGeneratorType:
|
||||
yield # confirm txid
|
||||
self.debug.press_yes()
|
||||
yield # confirm address
|
||||
self.debug.press_yes()
|
||||
# go back to address
|
||||
self.debug.press_no()
|
||||
# confirm address
|
||||
self.debug.press_yes()
|
||||
yield # confirm amount
|
||||
self.debug.press_yes()
|
||||
|
||||
yield # transaction summary, press info
|
||||
self.debug.click(buttons.CORNER_BUTTON)
|
||||
self.debug.click(buttons.CORNER_BUTTON)
|
||||
self.debug.press_yes()
|
||||
input_flow_t3t1 = input_flow_tt
|
||||
|
||||
|
||||
def lock_time_input_flow_tt(
|
||||
|
Loading…
Reference in New Issue
Block a user