test(node): improve unit test coverage for node module #2260
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.
Problem
The
crates/core/src/nodemodule had low unit test coverage, particularlymod.rsat 3.34% andnetwork_bridge.rsat 80.37%. This makes it harder to catch regressions and understand expected behavior of core node components.This Solution
Add comprehensive unit tests focusing on testable pure logic without requiring complex network mocking:
Coverage Improvements
node/mod.rsnode/network_bridge.rsnode/network_bridge/priority_select.rsTests Added
node/mod.rs:PeerIdtests (equality based on address, ordering, hashing, serialization, display)InitPeerNodeconstruction testsis_operation_completedfunction with various error conditionsnode/network_bridge.rs:ConnectionErrorvariant tests (clone, display, debug, from conversions)Files Still Needing Coverage
The following files have 0% coverage and would benefit from future test work:
p2p_impl.rs- Requires network mockingp2p_protoc.rs- Requires libp2p protocol mockingin_memory.rs- Test infrastructure codeThese are harder to test in isolation because they involve real network I/O and complex async coordination. The existing integration tests exercise much of this code.
Testing
All 78 node module tests pass:
[AI-assisted - Claude]