From 7f2244d481506a615a80a022a2bfc16bfa57e7fd Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Mon, 14 Apr 2025 16:27:01 +0200 Subject: [PATCH] fix(core): add hotfix for tests stuck on pairing dialog screen --- core/src/trezor/wire/thp/pairing_context.py | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/core/src/trezor/wire/thp/pairing_context.py b/core/src/trezor/wire/thp/pairing_context.py index 1b9e7f0b13..1d8cc7b71e 100644 --- a/core/src/trezor/wire/thp/pairing_context.py +++ b/core/src/trezor/wire/thp/pairing_context.py @@ -1,3 +1,4 @@ +import time from typing import TYPE_CHECKING from ubinascii import hexlify @@ -153,6 +154,30 @@ class PairingContext(Context): f"Allow {self.host_name} on {device_name} to pair with this Trezor?" ) + # TODO FIXME + # The subsequent code is a hotfix for the following issue: + # + # 1. `interact` - on line `result = await interact(` - calls `workflow.close_others` and `_button_request` + # 2. `workflow.close_others` may result in clearing of `context.CURRENT_CONTEXT` + # 3. `_button_request` uses `context.maybe_call` - sending of button request is ommited + # when `context.CURRENT_CONTEXT` is `None` + # 4. test gets stuck on the pairing dialog screen + # + # The hotfix performs `workflow.close_others()` and in case of clearing of `context.CURRENT_CONTEXT`, it + # is set to a functional value (`self`) + + workflow.close_others() + try: + _ = context.get_context() + except RuntimeError: + time.sleep(0.1) + context.CURRENT_CONTEXT = self + log.debug( + __name__, + "Hotfix for current context being destroyed by workflow.close_others", + ) + # --- HOTFIX END --- + result = await interact( trezorui_api.confirm_action( title="Before you continue", action=action_string, description=None