fix(core/debug): send current layout contents after watch_layout()

This should make tests more deterministic as previously whether
homescreen contents were sent or not was dependent on timing.

[no changelog]
mmilata/global-layout-rebased
Martin Milata 2 years ago
parent 305d8c399a
commit 877aea9f8b

@ -102,6 +102,7 @@ if __debug__:
async def return_layout_change() -> None:
content = await layout_change_chan.take()
layout_change_chan.putters.clear()
assert DEBUG_CONTEXT is not None
if storage.layout_watcher is LAYOUT_WATCHER_LAYOUT:
await DEBUG_CONTEXT.write(DebugLinkLayout(lines=content))
@ -126,6 +127,9 @@ if __debug__:
if msg.watch:
await ui.wait_until_layout_is_running()
storage.watch_layout_changes = bool(msg.watch)
if msg.watch and ui.RUNNING_LAYOUT:
ui.RUNNING_LAYOUT.should_notify_layout_change = False
notify_layout_change(ui.RUNNING_LAYOUT)
log.debug(__name__, "Watch layout changes: %s", storage.watch_layout_changes)
return Success()

@ -33,6 +33,7 @@ if __debug__:
class RustLayout(ui.Layout):
# pylint: disable=super-init-not-called
def __init__(self, layout: Any, is_backup: bool = False):
super().__init__()
self.layout = layout
self.timer = loop.Timer()
self.layout.attach_timer_fn(self.set_timer)

@ -141,6 +141,10 @@ if __debug__:
PROTOBUF_BUFFER_SIZE_DEBUG = 1024
WIRE_BUFFER_DEBUG = bytearray(PROTOBUF_BUFFER_SIZE_DEBUG)
if __debug__:
PROTOBUF_BUFFER_SIZE_DEBUG = 1024
WIRE_BUFFER_DEBUG = bytearray(PROTOBUF_BUFFER_SIZE_DEBUG)
class Context:
def __init__(self, iface: WireInterface, sid: int, buffer: bytearray) -> None:

@ -705,6 +705,14 @@ class TrezorClientDebugLink(TrezorClient):
# - TT < 2.3.0 does not reply to unknown debuglink messages due to a bug
self.debug.watch_layout(watch)
if self.version >= (2, 5, 2) and watch:
first_layout = self.debug.wait_layout()
assert(any(hs in first_layout.text) for hs in (
"Homescreen",
"Lockscreen",
"RecoveryHomescreen",
))
def __enter__(self) -> "TrezorClientDebugLink":
# For usage in with/expected_responses
if self.in_with_statement:

@ -178,8 +178,6 @@ VECTORS_MULTISIG = ( # script_type, bip48_type, address, xpubs, ignore_xpub_mag
)
# NOTE: contains wait_layout race that manifests on hw sometimes
@pytest.mark.flaky(max_runs=5)
@pytest.mark.skip_t1
@pytest.mark.multisig
@pytest.mark.parametrize(

@ -328,7 +328,7 @@ def test_signmessage_pagination(client: Client, message: str):
with client:
client.set_input_flow(input_flow)
client.debug.watch_layout(True)
client.watch_layout()
btc.sign_message(
client,
coin_name="Bitcoin",

Loading…
Cancel
Save