Skip to content

Commit

Permalink
feat(core): log ButtonRequests with names for easier debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
matejcik committed Nov 12, 2024
1 parent b2328a4 commit 34d97ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/trezor/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ def stop(self, _kill_taker: bool = True) -> None:

set_current_layout(None)
if __debug__:
if self.button_request_ack_pending:
raise wire.FirmwareError("button request ack pending")
self.notify_debuglink(None)

async def get_result(self) -> T:
Expand Down Expand Up @@ -416,12 +418,16 @@ async def _handle_usb_iface(self) -> None:
self.button_request_box,
)

if __debug__:
log.info(__name__, "ButtonRequest sent: %s", br_name)
await self.context.call(
ButtonRequest(
code=br_code, pages=self.layout.page_count(), name=br_name
),
ButtonAck,
)
if __debug__:
log.info(__name__, "ButtonRequest acked: %s", br_name)

if (
self.button_request_ack_pending
Expand Down
7 changes: 7 additions & 0 deletions core/src/trezor/ui/layouts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from trezor.messages import ButtonAck, ButtonRequest
from trezor.wire import ActionCancelled, context

if __debug__:
from trezor import log

if TYPE_CHECKING:
from typing import Any, Awaitable, Callable, TypeVar

Expand All @@ -23,9 +26,13 @@ async def _button_request(
pages: int = 0,
) -> None:
workflow.close_others()
if __debug__:
log.info(__name__, "ButtonRequest sent: %s", br_name)
await context.maybe_call(
ButtonRequest(code=code, pages=pages or None, name=br_name), ButtonAck
)
if __debug__:
log.info(__name__, "ButtonRequest acked: %s", br_name)


async def interact(
Expand Down

0 comments on commit 34d97ee

Please sign in to comment.