refactor(core): unify emulator detection
What changed, and why it matters
This is a small internal code cleanup in Trezor's test tooling. It replaces several direct checks for the string 'EMULATOR' with a single shared property, `is_emulator`. There is no change to the firmware's security behavior, no fix for a vulnerability, and no user-facing effect.
No security action needed. This is a benign refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors emulator detection in the Python test client. It adds TrezorTestContext.is_emulator = (self.features.fw_vendor == 'EMULATOR') and updates two test files to use client.is_emulator / session.test_ctx.is_emulator instead of comparing features.fw_vendor directly. The logic is identical; only the implementation is unified.
Changed components
python/src/trezorlib/debuglink.pytests/device_tests/evolu/test_get_delegated_identity_key.pytests/device_tests/test_firmware_hash.pyInspect captured patch +4 / −3
diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py
index e33fc226..c0704661 100644
--- a/python/src/trezorlib/debuglink.py
+++ b/python/src/trezorlib/debuglink.py
@@ -1324,6 +1324,7 @@ class TrezorTestContext:
self.debug.version = self.version = self.client.version
self.debug.model = self.model = self.client.model
self.layout_type = self.debug.layout_type
+ self.is_emulator = self.features.fw_vendor == "EMULATOR"
def _get_client(self) -> client.TrezorClient:
if self.protocol_version is ProtocolVersion.V1:
diff --git a/tests/device_tests/evolu/test_get_delegated_identity_key.py b/tests/device_tests/evolu/test_get_delegated_identity_key.py
index 6ba6421a..1e79ee0f 100644
--- a/tests/device_tests/evolu/test_get_delegated_identity_key.py
+++ b/tests/device_tests/evolu/test_get_delegated_identity_key.py
@@ -23,7 +23,7 @@ def test_evolu_get_delegated_identity_is_constant(client: Client):
def test_evolu_get_delegated_identity_test_vector(client: Client):
# on emulator, the master key is all zeroes. So the delegated identity key is constant.
- if client.get_session().features.fw_vendor != "EMULATOR":
+ if not client.is_emulator:
pytest.skip("Only for emulator")
private_key = get_delegated_identity_key(client)
diff --git a/tests/device_tests/test_firmware_hash.py b/tests/device_tests/test_firmware_hash.py
index 2bafab7c..1fec3125 100644
--- a/tests/device_tests/test_firmware_hash.py
+++ b/tests/device_tests/test_firmware_hash.py
@@ -17,7 +17,7 @@ FIRMWARE_LENGTHS = {
def test_firmware_hash_emu(session: Session) -> None:
- if session.features.fw_vendor != "EMULATOR":
+ if not session.test_ctx.is_emulator:
pytest.skip("Only for emulator")
data = b"\xff" * FIRMWARE_LENGTHS[session.model]
@@ -33,7 +33,7 @@ def test_firmware_hash_emu(session: Session) -> None:
def test_firmware_hash_hw(session: Session) -> None:
- if session.features.fw_vendor == "EMULATOR":
+ if session.test_ctx.is_emulator:
pytest.skip("Only for hardware")
# TODO get firmware image from outside the environment, check for actual result
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.