test(core): don't use Eckhart-specific homescreen in THP tests
What changed, and why it matters
This commit is a minor test-code cleanup. It removes a hard-coded Eckhart-specific JPEG homescreen path from a Trezor hardware wallet test suite and instead reuses a helper function that picks the correct image based on the device's screen layout type. There is no change to firmware behavior, no security fix, and no vulnerability.
No security action needed. This is a routine test maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff refactors two test files. In tests/device_tests/test_msg_applysettings.py, the Eckhart-vs-default homescreen JPEG selection logic is extracted into a helper function homescreen_jpeg_path(). In tests/device_tests/thp/test_abp.py, the previously hard-coded ‘test_bg_eckhart.jpg’ path is replaced by a call to that helper using session.debug.layout_type. This makes the THP (Trezor Host Protocol) test no longer assume an Eckhart layout. No firmware code is modified.
Changed components
tests/device_tests/test_msg_applysettings.pytests/device_tests/thp/test_abp.pyInspect captured patch +11 / −19
diff --git a/tests/device_tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py
index 43f58546..5984655e 100644
--- a/tests/device_tests/test_msg_applysettings.py
+++ b/tests/device_tests/test_msg_applysettings.py
@@ -229,14 +229,15 @@ def test_apply_homescreen_toif(session: Session):
device.apply_settings(session, homescreen=img)
+def homescreen_jpeg_path(layout_type: LayoutType) -> Path:
+ return HERE / (
+ "test_bg_eckhart.jpg" if layout_type is LayoutType.Eckhart else "test_bg.jpg"
+ )
+
+
@pytest.mark.models(skip=["legacy", "safe3"])
def test_apply_homescreen_jpeg(session: Session):
- file_name = (
- "test_bg_eckhart.jpg"
- if session.debug.layout_type is LayoutType.Eckhart
- else "test_bg.jpg"
- )
- with open(HERE / file_name, "rb") as f:
+ with open(homescreen_jpeg_path(session.debug.layout_type), "rb") as f:
img = f.read()
with session.test_ctx as client:
_set_expected_responses(client, homescreen=img)
@@ -250,13 +251,7 @@ def test_apply_homescreen_jpeg(session: Session):
@pytest.mark.models(skip=["legacy", "safe3", "eckhart"])
def test_apply_homescreen_jpeg_single_message(session: Session):
- file_name = (
- "test_bg_eckhart.jpg"
- if session.layout_type is LayoutType.Eckhart
- else "test_bg.jpg"
- )
-
- with open(HERE / file_name, "rb") as f:
+ with open(homescreen_jpeg_path(session.debug.layout_type), "rb") as f:
img = f.read()
with session.test_ctx as client:
_set_expected_responses(client)
diff --git a/tests/device_tests/thp/test_abp.py b/tests/device_tests/thp/test_abp.py
index 49f5e795..ef96b16f 100644
--- a/tests/device_tests/thp/test_abp.py
+++ b/tests/device_tests/thp/test_abp.py
@@ -1,7 +1,6 @@
import functools
import time
import typing as t
-from pathlib import Path
from unittest.mock import Mock
import pytest
@@ -10,6 +9,8 @@ from trezorlib import device, messages
from trezorlib.debuglink import DebugSession
from trezorlib.thp.client import TrezorClientThp
+from ..test_msg_applysettings import homescreen_jpeg_path
+
pytestmark = [pytest.mark.protocol("thp")]
@@ -48,9 +49,6 @@ def delay_call(func: t.Callable, seconds: float) -> t.Callable:
return wrapper
-HERE = Path(__file__).parent.resolve()
-
-
def test_delay_acks_from_host(session: DebugSession) -> None:
assert isinstance(session.client, TrezorClientThp)
channel = session.client.channel
@@ -60,7 +58,6 @@ def test_delay_acks_from_host(session: DebugSession) -> None:
session.client.ping("Should succeed after some retransmits")
session.client.ping("ButtonRequest should be retransmitted", button_protection=True)
- file_name = "test_bg_eckhart.jpg"
- with open(HERE.parent / file_name, "rb") as f:
+ with open(homescreen_jpeg_path(session.debug.layout_type), "rb") as f:
# Multiple requests and responses
device.apply_settings(session, homescreen=f.read())
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.