chore(core): reduce default value in `MockHID` c-tor
What changed, and why it matters
This is a tiny internal test-only change. It gives a default value to a fake USB-like object used only in automated tests, so callers no longer need to pass a placeholder number. It does not touch any real device code, user-facing behavior, or security logic.
No action required. This is a benign test refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies MockHID.__init__ in core/tests/mock_wire_interface.py to make its num parameter optional with a default of 42, then updates six test files to call MockHID() instead of MockHID(0xDEADBEEF). The commit message states this is preparation for using MockHID as CHANNEL_IFACE in a later commit. No runtime firmware or security code is changed.
Changed components
core/tests/mock_wire_interface.pycore/tests/test_storage.cache.pycore/tests/test_trezor.wire.codec.codec_v1.pycore/tests/test_trezor.wire.thp.pycore/tests/test_trezor.wire.thp.writer.pycore/tests/thp_common.pyInspect captured patch +6 / −6
diff --git a/core/tests/mock_wire_interface.py b/core/tests/mock_wire_interface.py
index 6d317a72d..24318103a 100644
--- a/core/tests/mock_wire_interface.py
+++ b/core/tests/mock_wire_interface.py
@@ -6,7 +6,7 @@ class MockHID:
TX_PACKET_LEN = 64
RX_PACKET_LEN = 64
- def __init__(self, num):
+ def __init__(self, num: int = 42):
self.num = num
self.data = []
self.packet = None
diff --git a/core/tests/test_storage.cache.py b/core/tests/test_storage.cache.py
index 63eb0ff2d..ee7d8e1b5 100644
--- a/core/tests/test_storage.cache.py
+++ b/core/tests/test_storage.cache.py
@@ -43,7 +43,7 @@ class TestStorageCache(unittest.TestCase):
super().__init__()
def setUp(self):
- self.interface = MockHID(0xDEADBEEF)
+ self.interface = MockHID()
cache.clear_all()
def test_new_channel_and_session(self):
diff --git a/core/tests/test_trezor.wire.codec.codec_v1.py b/core/tests/test_trezor.wire.codec.codec_v1.py
index 8bd296577..08be38072 100644
--- a/core/tests/test_trezor.wire.codec.codec_v1.py
+++ b/core/tests/test_trezor.wire.codec.codec_v1.py
@@ -20,7 +20,7 @@ def make_header(mtype, length):
class TestWireCodecV1(unittest.TestCase):
def setUp(self):
- self.interface = MockHID(0xDEADBEEF)
+ self.interface = MockHID()
def test_read_one_packet(self):
# zero length message - just a header
diff --git a/core/tests/test_trezor.wire.thp.py b/core/tests/test_trezor.wire.thp.py
index 09d35d66d..cd0af8d78 100644
--- a/core/tests/test_trezor.wire.thp.py
+++ b/core/tests/test_trezor.wire.thp.py
@@ -18,7 +18,7 @@ class TestTrezorHostProtocol(unittest.TestCase):
super().__init__()
def setUp(self):
- self.interface = MockHID(0xDEADBEEF)
+ self.interface = MockHID()
memory_manager.READ_BUFFER = bytearray(64)
memory_manager.WRITE_BUFFER = bytearray(256)
interface_manager.decode_iface = thp_common.dummy_decode_iface
diff --git a/core/tests/test_trezor.wire.thp.writer.py b/core/tests/test_trezor.wire.thp.writer.py
index 0f6110761..b3f33160c 100644
--- a/core/tests/test_trezor.wire.thp.writer.py
+++ b/core/tests/test_trezor.wire.thp.writer.py
@@ -75,7 +75,7 @@ class TestTrezorHostProtocolWriter(unittest.TestCase):
super().__init__()
def setUp(self):
- self.interface = MockHID(0xDEADBEEF)
+ self.interface = MockHID()
def test_write_empty_packet(self):
self.await_until_result(writer.write_packet_to_wire(self.interface, b""))
diff --git a/core/tests/thp_common.py b/core/tests/thp_common.py
index 490f9cc7a..b9a72bf3f 100644
--- a/core/tests/thp_common.py
+++ b/core/tests/thp_common.py
@@ -18,7 +18,7 @@ if utils.USE_THP:
from trezor.wire import WireInterface
def dummy_decode_iface(cached_iface: bytes):
- return MockHID(0xDEADBEEF)
+ return MockHID()
def dummy_encode_iface(iface: WireInterface):
return _MOCK_INTERFACE_HID
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.