1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 12:08:59 +00:00

core: debug messages when reading from wire

fixes #373
This commit is contained in:
matejcik 2019-07-30 17:59:03 +02:00 committed by matejcik
parent b9c978c1e2
commit cf70f82d90

View File

@ -101,7 +101,7 @@ class Context:
if __debug__:
log.debug(
__name__, "%s:%x read: %s", self.iface.iface_num(), self.sid, exptype
__name__, "%s:%x expect: %s", self.iface.iface_num(), self.sid, exptype
)
await reader.aopen() # wait for the message header
@ -111,6 +111,11 @@ class Context:
if exptype is None or reader.type != exptype.MESSAGE_WIRE_TYPE:
raise UnexpectedMessageError(reader)
if __debug__:
log.debug(
__name__, "%s:%x read: %s", self.iface.iface_num(), self.sid, exptype
)
# parse the message and return it
return await protobuf.load_message(reader, exptype)
@ -120,7 +125,7 @@ class Context:
if __debug__:
log.debug(
__name__,
"%s:%x read: %s",
"%s:%x expect: %s",
self.iface.iface_num(),
self.sid,
allowed_types,
@ -136,6 +141,11 @@ class Context:
# find the protobuf type
exptype = messages.get_type(reader.type)
if __debug__:
log.debug(
__name__, "%s:%x read: %s", self.iface.iface_num(), self.sid, exptype
)
# parse the message and return it
return await protobuf.load_message(reader, exptype)
@ -223,6 +233,10 @@ async def protobuf_workflow(
from trezor.messages.Failure import Failure
req = await protobuf.load_message(reader, messages.get_type(reader.type))
if __debug__:
log.debug(__name__, "%s:%x request: %s", ctx.iface.iface_num(), ctx.sid, req)
try:
res = await handler(ctx, req, *args)
except UnexpectedMessageError: