refactor:rename-project-to-openhop

This commit is contained in:
Lloyd
2026-06-24 23:27:49 +01:00
parent 2b07e79ccd
commit 2b67dea96b
83 changed files with 719 additions and 649 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ from typing import Any, cast
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from pymc_core.companion.constants import RESP_CODE_NO_MORE_MESSAGES
from openhop_core.companion.constants import RESP_CODE_NO_MORE_MESSAGES
from repeater.companion.bridge import RepeaterCompanionBridge, _to_json_safe
from repeater.companion.frame_server import CompanionFrameServer
+1 -1
View File
@@ -2,7 +2,7 @@
import pytest
from pymc_core import LocalIdentity
from openhop_core import LocalIdentity
from repeater.companion.bridge import RepeaterCompanionBridge, _prefs_bytes_from_json
+1 -1
View File
@@ -22,7 +22,7 @@ from repeater.companion.utils import (
validate_companion_config_capacity,
)
# pymc_core defaults (CompanionBridge / ContactStore)
# openhop_core defaults (CompanionBridge / ContactStore)
_DEFAULT_MAX_CONTACTS = 1000
+4 -4
View File
@@ -1,5 +1,5 @@
"""
tests for pyMC_Repeater engine.py RepeaterHandler.
tests for openhop-repeater engine.py RepeaterHandler.
Covers: flood_forward, direct_forward, process_packet, duplicate detection,
mark_seen, validate_packet, packet scoring, TX delay, cache management,
@@ -12,8 +12,8 @@ import time
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from pymc_core.protocol import Packet, PacketBuilder
from pymc_core.protocol.constants import (
from openhop_core.protocol import Packet, PacketBuilder
from openhop_core.protocol.constants import (
MAX_PATH_SIZE,
PH_ROUTE_MASK,
PH_TYPE_SHIFT,
@@ -1754,7 +1754,7 @@ class TestMissedEngineBranches:
pkt = _make_transport_flood_packet(payload=b"\x01\x02", path=b"")
pkt.transport_codes = [0xCAFE, 0xBEEF]
with patch("pymc_core.protocol.transport_keys.calc_transport_code", return_value=0xCAFE):
with patch("openhop_core.protocol.transport_keys.calc_transport_code", return_value=0xCAFE):
allowed_1, reason_1 = handler._check_transport_codes(pkt)
allowed_2, reason_2 = handler._check_transport_codes(pkt)
+3 -3
View File
@@ -1,7 +1,7 @@
"""
Tests for flood packet loop detection and duplicate suppression.
Exercises the real RepeaterHandler engine with real pymc_core Packet/PathUtils
Exercises the real RepeaterHandler engine with real openhop_core Packet/PathUtils
objects to verify:
- Duplicate packet suppression via calculate_packet_hash (SHA256-based)
- Loop detection modes (off, minimal, moderate, strict) with real path bytes
@@ -15,8 +15,8 @@ objects to verify:
from unittest.mock import MagicMock, patch
from pymc_core.protocol import Packet, PathUtils
from pymc_core.protocol.constants import (
from openhop_core.protocol import Packet, PathUtils
from openhop_core.protocol.constants import (
ROUTE_TYPE_FLOOD,
ROUTE_TYPE_TRANSPORT_FLOOD,
)
@@ -56,7 +56,7 @@ async def test_path_helper_updates_client_out_path_on_valid_decrypt():
packet = _PathPacket(payload=b"\x11\x22\xaa\xbb\xcc")
with patch(
"pymc_core.protocol.crypto.CryptoUtils.mac_then_decrypt", return_value=b"\x02\x99\x88\x01"
"openhop_core.protocol.crypto.CryptoUtils.mac_then_decrypt", return_value=b"\x02\x99\x88\x01"
):
handled = await helper.process_path_packet(packet)
@@ -82,7 +82,7 @@ async def test_path_helper_returns_false_for_non_matching_or_invalid_inputs():
is False
)
with patch("pymc_core.protocol.crypto.CryptoUtils.mac_then_decrypt", return_value=None):
with patch("openhop_core.protocol.crypto.CryptoUtils.mac_then_decrypt", return_value=None):
assert await helper.process_path_packet(_PathPacket(payload=b"\x11\x22\xaa\xbb")) is False
@@ -356,7 +356,7 @@ async def test_text_helper_send_cli_reply_uses_direct_path_from_client():
reply_packet = SimpleNamespace(path=bytearray(), path_len=0)
with (
patch("pymc_core.protocol.PacketBuilder.create_datagram", return_value=reply_packet),
patch("openhop_core.protocol.PacketBuilder.create_datagram", return_value=reply_packet),
patch("repeater.handler_helpers.text.asyncio.sleep", new_callable=AsyncMock),
):
await helper._send_cli_reply(
@@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from pymc_core.protocol.constants import PAYLOAD_TYPE_ANON_REQ, ROUTE_TYPE_DIRECT
from openhop_core.protocol.constants import PAYLOAD_TYPE_ANON_REQ, ROUTE_TYPE_DIRECT
from repeater.handler_helpers.discovery import DiscoveryHelper
from repeater.handler_helpers.login import LoginHelper
from repeater.handler_helpers.trace import TraceHelper
@@ -258,7 +258,7 @@ def test_discovery_send_response_without_injector_is_safe():
helper = DiscoveryHelper(local_identity=FakeIdentity(0x42), packet_injector=None)
with patch(
"pymc_core.protocol.packet_builder.PacketBuilder.create_discovery_response",
"openhop_core.protocol.packet_builder.PacketBuilder.create_discovery_response",
return_value=object(),
):
helper._send_discovery_response(tag=5, node_type=2, inbound_snr=1.0, prefix_only=False)
+1 -1
View File
@@ -241,7 +241,7 @@ async def test_send_advert_branches_and_success_path():
)
packet = SimpleNamespace(calculate_packet_hash=lambda: b"\xab" * 16)
with patch("pymc_core.protocol.PacketBuilder.create_advert", return_value=packet):
with patch("openhop_core.protocol.PacketBuilder.create_advert", return_value=packet):
ok = await daemon.send_advert()
assert ok is True
+1 -1
View File
@@ -46,7 +46,7 @@ async def test_load_additional_identities_valid_and_invalid_entries():
daemon.identity_manager = SimpleNamespace(list_identities=lambda: [1, 2])
daemon._register_identity_everywhere = MagicMock(return_value=True)
with patch("pymc_core.LocalIdentity", _FakeLocalIdentity):
with patch("openhop_core.LocalIdentity", _FakeLocalIdentity):
await daemon._load_additional_identities()
# Only valid entries should be registered (including 64-byte firmware keys).
+1 -1
View File
@@ -32,7 +32,7 @@ class _FakeIdentity:
def _make_config(format_value: str = "letsmesh", iata_code: str = "LAX") -> dict:
"""Minimal pyMC_Repeater config sufficient to construct MeshCoreToMqttPusher."""
"""Minimal openhop-repeater config sufficient to construct MeshCoreToMqttPusher."""
return {
"repeater": {"node_name": "test-node"},
"radio": {
+12 -12
View File
@@ -19,18 +19,18 @@ import time
import unittest
from unittest.mock import AsyncMock, MagicMock, patch
from pymc_core.node.handlers.ack import AckHandler
from pymc_core.node.handlers.advert import AdvertHandler
from pymc_core.node.handlers.control import ControlHandler
from pymc_core.node.handlers.group_text import GroupTextHandler
from pymc_core.node.handlers.login_response import LoginResponseHandler
from pymc_core.node.handlers.login_server import LoginServerHandler
from pymc_core.node.handlers.path import PathHandler
from pymc_core.node.handlers.protocol_request import ProtocolRequestHandler
from pymc_core.node.handlers.protocol_response import ProtocolResponseHandler
from pymc_core.node.handlers.text import TextMessageHandler
from pymc_core.node.handlers.trace import TraceHandler
from pymc_core.protocol.constants import ROUTE_TYPE_DIRECT
from openhop_core.node.handlers.ack import AckHandler
from openhop_core.node.handlers.advert import AdvertHandler
from openhop_core.node.handlers.control import ControlHandler
from openhop_core.node.handlers.group_text import GroupTextHandler
from openhop_core.node.handlers.login_response import LoginResponseHandler
from openhop_core.node.handlers.login_server import LoginServerHandler
from openhop_core.node.handlers.path import PathHandler
from openhop_core.node.handlers.protocol_request import ProtocolRequestHandler
from openhop_core.node.handlers.protocol_response import ProtocolResponseHandler
from openhop_core.node.handlers.text import TextMessageHandler
from openhop_core.node.handlers.trace import TraceHandler
from openhop_core.protocol.constants import ROUTE_TYPE_DIRECT
from repeater.packet_router import (
PacketRouter,
+3 -3
View File
@@ -8,9 +8,9 @@ returns 2 or 3. The dispatcher applies this in send_packet() before transmit.
import pytest
from pymc_core.node.dispatcher import Dispatcher
from pymc_core.protocol import Packet
from pymc_core.protocol.constants import (
from openhop_core.node.dispatcher import Dispatcher
from openhop_core.protocol import Packet
from openhop_core.protocol.constants import (
PAYLOAD_TYPE_ADVERT,
PH_TYPE_SHIFT,
ROUTE_TYPE_FLOOD,
+6 -6
View File
@@ -1,5 +1,5 @@
"""
Integration tests for multi-byte path hash support using real pymc_core protocol objects.
Integration tests for multi-byte path hash support using real openhop_core protocol objects.
Exercises actual Packet, PathUtils, PacketBuilder, and engine forwarding
rather than mocking the protocol layer. Covers:
@@ -16,9 +16,9 @@ import struct
from unittest.mock import MagicMock, patch
import pytest
from pymc_core.node.handlers.trace import TraceHandler
from pymc_core.protocol import Packet, PacketBuilder, PathUtils
from pymc_core.protocol.constants import (
from openhop_core.node.handlers.trace import TraceHandler
from openhop_core.protocol import Packet, PacketBuilder, PathUtils
from openhop_core.protocol.constants import (
MAX_PATH_SIZE,
PATH_HASH_COUNT_MASK,
PATH_HASH_SIZE_SHIFT,
@@ -730,7 +730,7 @@ class TestTraceHelperMultibyte:
"""TraceHelper._should_forward_trace with 2-byte TRACE payload hashes."""
def test_should_forward_when_next_hop_matches_pubkey_prefix(self):
from pymc_core.protocol import LocalIdentity
from openhop_core.protocol import LocalIdentity
from repeater.handler_helpers.trace import TraceHelper
@@ -752,7 +752,7 @@ class TestTraceHelperMultibyte:
assert th._should_forward_trace(pkt, trace_bytes, flags, hash_width)
def test_should_not_forward_when_next_hop_mismatch(self):
from pymc_core.protocol import LocalIdentity
from openhop_core.protocol import LocalIdentity
from repeater.handler_helpers.trace import TraceHelper
+3 -3
View File
@@ -1,9 +1,9 @@
from unittest.mock import patch
import yaml
from pymc_core.protocol.constants import PAYLOAD_TYPE_GRP_TXT
from pymc_core.protocol.identity import LocalIdentity
from pymc_core.protocol.packet_builder import PacketBuilder
from openhop_core.protocol.constants import PAYLOAD_TYPE_GRP_TXT
from openhop_core.protocol.identity import LocalIdentity
from openhop_core.protocol.packet_builder import PacketBuilder
from repeater.policy_engine import PolicyEngine
+1 -1
View File
@@ -1,6 +1,6 @@
"""Regression tests guarding against Python 3.10 compatibility breakage.
pyMC Repeater supports Python 3.10+ (LuckFox Pico Ultra ships with 3.10).
openHop Repeater supports Python 3.10+ (LuckFox Pico Ultra ships with 3.10).
These tests scan the source tree statically so regressions are caught in CI
without needing a 3.10 interpreter in the test environment.
"""
+11 -11
View File
@@ -20,7 +20,7 @@ def test_get_radio_for_board_passes_en_pins(monkeypatch):
return _DummyRadio()
monkeypatch.setattr(
"pymc_core.hardware.sx1262_wrapper.SX1262Radio",
"openhop_core.hardware.sx1262_wrapper.SX1262Radio",
_DummySX1262Radio,
)
@@ -81,7 +81,7 @@ def _pymc_radio_cfg():
def test_get_radio_for_board_pymc_tcp(monkeypatch):
pytest.importorskip("pymc_core.hardware.tcp_radio")
pytest.importorskip("openhop_core.hardware.tcp_radio")
captured = {}
class _DummyTCPLoRaRadio(_DummyRadio):
@@ -89,7 +89,7 @@ def test_get_radio_for_board_pymc_tcp(monkeypatch):
captured.update(kwargs)
monkeypatch.setattr(
"pymc_core.hardware.tcp_radio.TCPLoRaRadio",
"openhop_core.hardware.tcp_radio.TCPLoRaRadio",
_DummyTCPLoRaRadio,
)
@@ -119,10 +119,10 @@ def test_get_radio_for_board_pymc_tcp(monkeypatch):
def test_get_radio_for_board_pymc_tcp_requires_host(monkeypatch):
pytest.importorskip("pymc_core.hardware.tcp_radio")
pytest.importorskip("openhop_core.hardware.tcp_radio")
monkeypatch.setattr(
"pymc_core.hardware.tcp_radio.TCPLoRaRadio",
"openhop_core.hardware.tcp_radio.TCPLoRaRadio",
lambda **kwargs: _DummyRadio(),
)
@@ -137,7 +137,7 @@ def test_get_radio_for_board_pymc_tcp_requires_host(monkeypatch):
def test_get_radio_for_board_pymc_usb(monkeypatch):
pytest.importorskip("pymc_core.hardware.usb_radio")
pytest.importorskip("openhop_core.hardware.usb_radio")
captured = {}
class _DummyUSBLoRaRadio(_DummyRadio):
@@ -145,7 +145,7 @@ def test_get_radio_for_board_pymc_usb(monkeypatch):
captured.update(kwargs)
monkeypatch.setattr(
"pymc_core.hardware.usb_radio.USBLoRaRadio",
"openhop_core.hardware.usb_radio.USBLoRaRadio",
_DummyUSBLoRaRadio,
)
@@ -170,10 +170,10 @@ def test_get_radio_for_board_pymc_usb(monkeypatch):
def test_get_radio_for_board_pymc_usb_requires_port(monkeypatch):
pytest.importorskip("pymc_core.hardware.usb_radio")
pytest.importorskip("openhop_core.hardware.usb_radio")
monkeypatch.setattr(
"pymc_core.hardware.usb_radio.USBLoRaRadio",
"openhop_core.hardware.usb_radio.USBLoRaRadio",
lambda **kwargs: _DummyRadio(),
)
@@ -195,7 +195,7 @@ def test_get_radio_for_board_pymc_usb_requires_port(monkeypatch):
def _kiss_capture_radio_config(monkeypatch):
"""Patch KissModemWrapper to capture the radio_config it is built with."""
pytest.importorskip("pymc_core.hardware.kiss_modem_wrapper")
pytest.importorskip("openhop_core.hardware.kiss_modem_wrapper")
captured = {}
class _DummyKissWrapper(_DummyRadio):
@@ -203,7 +203,7 @@ def _kiss_capture_radio_config(monkeypatch):
captured["kwargs"] = kwargs
monkeypatch.setattr(
"pymc_core.hardware.kiss_modem_wrapper.KissModemWrapper",
"openhop_core.hardware.kiss_modem_wrapper.KissModemWrapper",
_DummyKissWrapper,
)
return captured
+6 -6
View File
@@ -68,7 +68,7 @@ def test_generate_transport_key_uses_implicit_hashtag_region(tmp_path, monkeypat
h = _make_handler(tmp_path)
captured = {}
fake_transport_keys = types.ModuleType("pymc_core.protocol.transport_keys")
fake_transport_keys = types.ModuleType("openhop_core.protocol.transport_keys")
def _fake_get_auto_key_for(name: str) -> bytes:
captured["name"] = name
@@ -76,15 +76,15 @@ def test_generate_transport_key_uses_implicit_hashtag_region(tmp_path, monkeypat
fake_transport_keys.get_auto_key_for = _fake_get_auto_key_for
fake_protocol = types.ModuleType("pymc_core.protocol")
fake_protocol = types.ModuleType("openhop_core.protocol")
fake_protocol.transport_keys = fake_transport_keys
fake_core = types.ModuleType("pymc_core")
fake_core = types.ModuleType("openhop_core")
fake_core.protocol = fake_protocol
monkeypatch.setitem(sys.modules, "pymc_core", fake_core)
monkeypatch.setitem(sys.modules, "pymc_core.protocol", fake_protocol)
monkeypatch.setitem(sys.modules, "pymc_core.protocol.transport_keys", fake_transport_keys)
monkeypatch.setitem(sys.modules, "openhop_core", fake_core)
monkeypatch.setitem(sys.modules, "openhop_core.protocol", fake_protocol)
monkeypatch.setitem(sys.modules, "openhop_core.protocol.transport_keys", fake_transport_keys)
generated = h.generate_transport_key("eu")
generated_bytes = base64.b64decode(generated)
@@ -29,7 +29,7 @@ def _make_collector() -> StorageCollector:
patch("repeater.data_acquisition.storage_collector.RRDToolHandler"),
patch("repeater.data_acquisition.hardware_stats.HardwareStatsCollector"),
):
collector = StorageCollector(config={"storage": {"storage_dir": "/tmp/pymc_repeater_test"}})
collector = StorageCollector(config={"storage": {"storage_dir": "/tmp/openhop_repeater_test"}})
# Stop any real stats-broadcast thread started during construction so the tests
# drive the loop deterministically.
+1 -1
View File
@@ -33,7 +33,7 @@ def _fake_thread(*args, **kwargs):
def test_jwt_warning_fix_guard():
# Guard test file import path and ensure this module executes in suite.
assert ue.PACKAGE_NAME == "pymc_repeater"
assert ue.PACKAGE_NAME == "openhop_repeater"
def test_has_update_paths():