refactor: clean up PeerSessionManager and CallController integration

- Split PeerSession.kt out of PeerSessionManager.kt (types, interface,
  manager are now in separate files)
- Remove webRtcSessions duplication in CallController — PeerSessionManager
  is now the single source of truth for session tracking; WebRtcCallSession
  is retrieved via the adapter cast when WebRTC-specific APIs are needed
- Initialize PeerSessionManager eagerly with localPubKey (passed to
  CallController constructor) instead of lazy suspend init — fixes early
  ICE candidates being silently dropped before first suspend call
- Extract FakePeerSession into its own file for reuse across test files
- Remove assertion-only glare tiebreaker tests from NipACStateMachineTest
  (now properly tested with real logic in PeerSessionManagerTest)

https://claude.ai/code/session_01AfRYTRCvtKqqDxeKQujUrx
This commit is contained in:
Claude
2026-04-05 15:38:28 +00:00
parent e9f1fcbd2a
commit 6fbbcbbf3b
7 changed files with 207 additions and 212 deletions
@@ -394,27 +394,11 @@ class NipACStateMachineTest {
}
}
// ========================================================================
// 9. Renegotiation Glare: Pubkey Comparison Tiebreaker
// ========================================================================
@Test
fun renegotiationGlareTiebreaker_higherPubkeyWins() {
// Per spec: "the peer with the higher pubkey wins"
// alice < bob (lexicographically: 'a' < 'b')
assertTrue(alice < bob, "Precondition: alice pubkey < bob pubkey")
// So bob's offer takes priority, alice must rollback
}
@Test
fun calleeToCalleeMeshGlare_lowerPubkeyInitiates() {
// Per spec: "the peer with the lexicographically lower pubkey initiates the offer"
assertTrue(alice < bob)
// Alice (lower) should initiate, Bob (higher) waits
}
// Renegotiation glare and callee-to-callee mesh tiebreakers are tested in
// PeerSessionManagerTest (commons/commonTest/) where the actual logic lives.
// ========================================================================
// 10. Event Kind Constants
// 9. Event Kind Constants
// ========================================================================
@Test