Skip to content

Add 111 unit tests for sync layer and fix HostInfoFilter DNS resolution#3816

Merged
guiyanakuang merged 1 commit intomainfrom
test/issue-3815-sync-layer-unit-tests
Feb 9, 2026
Merged

Add 111 unit tests for sync layer and fix HostInfoFilter DNS resolution#3816
guiyanakuang merged 1 commit intomainfrom
test/issue-3815-sync-layer-unit-tests

Conversation

@guiyanakuang
Copy link
Copy Markdown
Member

Closes #3815

Summary

  • Add 111 unit tests across 6 test classes covering the core sync/discovery/connection layer
  • Extract TokenCacheApi interface from TokenCache object for clean dependency injection in tests
  • Fix HostInfoFilter.resolveIpBytes() to reject non-IP strings that trigger unintended DNS resolution

Test classes

Class Tests Coverage
SyncResolverTest 50 Event dispatch, state transitions, heartbeat, token cache, trust
GeneralSyncHandlerTest 20 State machine, API delegation, address resolution
SyncPasteTaskExecutorTest 13 Eligibility filtering, sync execution, retry logic
TelnetHelperTest 11 Single host telnet, parallel switchHost racing
GeneralNearbyDeviceManagerTest 10 Device add/remove, self-filtering, blacklist
SyncPollingManagerTest 7 Exponential backoff, reset, cancellation

Production changes

  • TokenCache.kt: Extract TokenCacheApi interface; TokenCache object implements it
  • SyncResolver.kt: Accept TokenCacheApi instead of TokenCache concrete type
  • DesktopModule.kt: Bind TokenCacheApi in Koin
  • HostInfoFilter.kt: Add looksLikeIpLiteral() guard to prevent DNS resolution of non-IP strings

Test plan

  • All 111 new tests pass
  • All pre-existing tests pass (HostInfoFilterTest now also passes)
  • ktlintFormat passes

🤖 Generated with Claude Code

…tion

Add comprehensive test coverage for the core sync/discovery/connection
subsystem, and fix HostInfoFilter to reject non-IP strings that could
trigger unintended DNS resolution.

Test classes:
- SyncResolverTest (50): event dispatch, state transitions, heartbeat
- GeneralSyncHandlerTest (20): state machine, API delegation
- SyncPasteTaskExecutorTest (13): eligibility, sync execution, retry
- TelnetHelperTest (11): single host telnet, parallel switchHost
- GeneralNearbyDeviceManagerTest (10): device add/remove, blacklist
- SyncPollingManagerTest (7): backoff, reset, cancellation
- SyncTestFixtures: shared factory methods

Production changes:
- Extract TokenCacheApi interface for testable dependency injection
- Add looksLikeIpLiteral() guard in HostInfoFilter.resolveIpBytes()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@guiyanakuang guiyanakuang merged commit 2369e45 into main Feb 9, 2026
2 checks passed
@guiyanakuang guiyanakuang deleted the test/issue-3815-sync-layer-unit-tests branch February 9, 2026 11:59
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.

Add unit tests for sync/discovery/connection layer and fix HostInfoFilter DNS resolution

1 participant