Skip to content

Add unit tests for all three interface modules (123 tests) - #3

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783038584-add-unit-tests
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783038584-add-unit-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Adds a comprehensive unit test suite (123 tests) covering all three interface modules. Previously the repo had zero test coverage.

Test infrastructure (tests/conftest.py): Lightweight RNS and meshcore stubs injected into sys.modules and builtins so tests run without hardware or external library dependencies. Interface instances are created via object.__new__() to bypass __init__ (which opens serial/BLE/TCP connections) and test methods in isolation.

Coverage by module:

MeshCore_Dynamic_Interface — 55 tests:

  • _PacketHandler fragmentation: encoding, base64 round-trip reassembly, payload size customization, boundary conditions, 32-bit pkt_id wrap
  • RNS header parsing: _is_broadcast_packet for all packet/dest type combinations, _extract_rns_token for single/two-byte headers, _link_id_from_lr_packet SHA-256 derivation
  • Peer discovery: _handle_bind parsing with capability (R/E), reverse peer table population, _resolve_sender_key prefix matching
  • _process_tunnel_text: single/multi-fragment reassembly, sliding-window deduplication, echo rejection, malformed input handling
  • Rate limiting: announce rate suppression, path request burst window pass-through, disable via rate=0
  • Routing: broadcast→channel, unicast→direct with known route, fallback on missing route or disabled direct API

MeshCore_Channel_Interface — 37 tests:

  • _PacketHandler 9-byte header (magic+src_id) fragmentation and round-trip reassembly
  • _derive_local_src_id deterministic derivation
  • _process_tunnel_text: delivery, multi-fragment reassembly, own-echo/bad-magic/duplicate rejection, firmware sender-prefix stripping, empty payload handling
  • processOutgoing/processIncoming enqueuing and delivery guards

MeshCore_Interface (legacy) — 31 tests:

  • PacketHandler.split_data fragmentation, metadata format (struct.pack("Bb")), positive/negative key lookup
  • _payload_for_send/_payload_from_received: base64 encode/decode, double-encoding, dict extraction (payload/data/text keys), bytes passthrough, latin-1 fallback
  • _resolve_destination: dict/pubkey/prefix/advert name resolution
  • should_ingress_limit, set_debug_level

Link to Devin session: https://app.devin.ai/sessions/653250318cda412a821e97141e0fb4a0
Requested by: @comms-engineer

Add comprehensive unit test suite covering the core logic of all three
interface modules: MeshCore_Dynamic_Interface, MeshCore_Channel_Interface,
and MeshCore_Interface.

Test infrastructure:
- conftest.py with RNS and meshcore mock stubs so tests run without
  external hardware or library dependencies
- All tests use object.__new__() to bypass __init__ and test methods
  in isolation

Test coverage by module:

MeshCore_Dynamic_Interface:
- _PacketHandler: fragmentation, encoding, reassembly round-trips,
  boundary conditions, payload size customization
- RNS header parsing: _is_broadcast_packet for all packet/dest type
  combinations, _extract_rns_token for single/two-byte headers,
  _link_id_from_lr_packet hash derivation
- Peer discovery: _handle_bind parsing with capability (R/E) and
  reverse peer table population, _resolve_sender_key prefix matching
- Tunnel text processing: single/multi-fragment reassembly,
  deduplication, echo rejection, invalid input handling
- Rate limiting: announce rate suppression, burst window pass-through,
  different-dest independence, disable via rate=0
- Routing decisions: broadcast vs direct routing, fallback on missing
  route or disabled direct API, pkt_id increment/wrap

MeshCore_Channel_Interface:
- _PacketHandler: 9-byte header (magic+src_id) fragmentation and
  round-trip reassembly
- _derive_local_src_id: deterministic derivation, secret sensitivity
- Tunnel pipeline: fragment delivery, multi-fragment reassembly,
  own-echo suppression, bad-magic rejection, deduplication,
  sender-prefix stripping, empty/invalid payload handling
- processOutgoing: fragment enqueuing, offline drop, pkt_id wrap

MeshCore_Interface (legacy):
- PacketHandler: split_data even fragmentation, metadata format,
  positive/negative key lookup, reassembly from fragments
- _payload_for_send / _payload_from_received: base64 encode/decode,
  double-encoding, dict extraction, bytes passthrough, fallback
- _resolve_destination: dict/pubkey/prefix/advert name resolution
- should_ingress_limit, set_debug_level

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@comms-engineer comms-engineer self-assigned this Jul 3, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant