Add unit tests for all three interface modules (123 tests) - #3
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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): LightweightRNSandmeshcorestubs injected intosys.modulesandbuiltinsso tests run without hardware or external library dependencies. Interface instances are created viaobject.__new__()to bypass__init__(which opens serial/BLE/TCP connections) and test methods in isolation.Coverage by module:
MeshCore_Dynamic_Interface— 55 tests:_PacketHandlerfragmentation: encoding, base64 round-trip reassembly, payload size customization, boundary conditions, 32-bitpkt_idwrap_is_broadcast_packetfor all packet/dest type combinations,_extract_rns_tokenfor single/two-byte headers,_link_id_from_lr_packetSHA-256 derivation_handle_bindparsing with capability (R/E), reverse peer table population,_resolve_sender_keyprefix matching_process_tunnel_text: single/multi-fragment reassembly, sliding-window deduplication, echo rejection, malformed input handlingrate=0MeshCore_Channel_Interface— 37 tests:_PacketHandler9-byte header (magic+src_id) fragmentation and round-trip reassembly_derive_local_src_iddeterministic derivation_process_tunnel_text: delivery, multi-fragment reassembly, own-echo/bad-magic/duplicate rejection, firmware sender-prefix stripping, empty payload handlingprocessOutgoing/processIncomingenqueuing and delivery guardsMeshCore_Interface(legacy) — 31 tests:PacketHandler.split_datafragmentation, metadata format (struct.pack("Bb")), positive/negative key lookup_payload_for_send/_payload_from_received: base64 encode/decode, double-encoding, dict extraction (payload/data/textkeys), bytes passthrough, latin-1 fallback_resolve_destination: dict/pubkey/prefix/advert name resolutionshould_ingress_limit,set_debug_levelLink to Devin session: https://app.devin.ai/sessions/653250318cda412a821e97141e0fb4a0
Requested by: @comms-engineer