From af1c79a9f25da378fa6743624450ed55d82774bd Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Fri, 14 Mar 2025 21:44:45 +0100 Subject: [PATCH] fixup! chore(tests): adapt testing framework to session based [no changelog] --- python/src/trezorlib/client.py | 9 +++++++++ python/src/trezorlib/debuglink.py | 4 ++++ tests/conftest.py | 6 +----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/python/src/trezorlib/client.py b/python/src/trezorlib/client.py index 989527f6bb..8a3f229e50 100644 --- a/python/src/trezorlib/client.py +++ b/python/src/trezorlib/client.py @@ -227,6 +227,15 @@ class TrezorClient: protocol = ProtocolV2Channel(self.transport, self.mapping) return protocol + def reset_protocol(self): + if self._protocol_version == ProtocolVersion.PROTOCOL_V1: + self.protocol = ProtocolV1Channel(self.transport, self.mapping) + elif self._protocol_version == ProtocolVersion.PROTOCOL_V2: + self.protocol = ProtocolV2Channel(self.transport, self.mapping) + else: + assert False + self._features = None + def is_outdated(self) -> bool: if self.features.bootloader_mode: return False diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index aa176a0ae9..631b960d00 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -1471,6 +1471,10 @@ class TrezorClientDebugLink(TrezorClient): raise RuntimeError("Unexpected call") + def reset_protocol(self): + super().reset_protocol() + self._seedless_session = self.get_seedless_session(new_session=True) + def load_device( session: "Session", diff --git a/tests/conftest.py b/tests/conftest.py index 831ed74002..c09e35dab0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -340,11 +340,7 @@ def _client_unlocked( # Get a new client _raw_client = _get_raw_client(request) - _raw_client.protocol = None - _raw_client.__init__( - transport=_raw_client.transport, - auto_interact=_raw_client.debug.allow_interactions, - ) + _raw_client.reset_protocol() if not _raw_client.features.bootloader_mode: _raw_client.refresh_features()