4abca173f83c

test: pin 2-paired-device reconcile counts (v2.9.18)

Trio is now complete. The first test in the suite (N=1/0 eligible) covers the 'no peer passes the filter' branch; this one covers the common branch (both peers pass) and pins the wire output seen at 00:14:42.592 after Firefox + Chrome both paired. - New test: 'reconcile logs both paired devices as eligible when 2 direct-trust extensions are paired' — fake device store with Firefox + Chrome (both deviceType=extension, trustSource=direct), asserts the log line is exactly 'cloud-relay: reconcile start — 2 paired device(s), 2 eligible'. Catches any off-by-one or stale-cache bug in the inventory log. - Test runs in 27ms. Reuses the existing fake PairedDeviceRegistry stub and capturePeachSyncLogs helper — no new test infrastructure. CONTINUITY.md updated; checkpoint 15910b3d75f4 is the pre-edit restore point. Gate: testDebugUnitTest --tests com.peachpasswords.sync.CloudRelayReconnectListenerTest — 11 tests, 0 failures, 0 errors.

time
2026-07-31 13:06 UTC · 2 months ago
machine
koh2
parent
453bcdaba9ef
2 files VERSION+1 −1app/src/test/java/com/peachpasswords/sync/CloudRelayReconnectListenerTest.kt+41 −0
VERSION+1 −1
@@ -1 +1 @@1-2.9.17\ No newline at end of file1+2.9.18\ No newline at end of file

view file

app/src/test/java/com/peachpasswords/sync/CloudRelayReconnectListenerTest.kt+41 −0
@@ -139,6 +139,47 @@139139         )140140     }141141 142+    @Test143+    fun `reconcile logs both paired devices as eligible when 2 direct-trust extensions are paired`() = runBlocking {144+        // This is the wire output visible at the 00:14:42.592 moment in the145+        // logcat you saw after Firefox + Chrome both paired. The count has to146+        // grow as a new device is added — any off-by-one or stale-cache bug147+        // shows up here as the wrong N.148+        val devices = listOf(149+            PairedDevice(150+                deviceId = "firefox",151+                deviceName = "Firefox",152+                deviceType = "extension",153+                trustSource = "direct",154+                pairedAt = 1L,155+            ),156+            PairedDevice(157+                deviceId = "chrome",158+                deviceName = "Chrome",159+                deviceType = "extension",160+                trustSource = "direct",161+                pairedAt = 2L,162+            ),163+        )164+        val fakeDeviceStore = object : PairedDeviceRegistry {165+            override fun getAll() = devices166+            override fun get(id: String) = devices.firstOrNull { it.deviceId == id }167+            override fun upsert(device: PairedDevice) = Unit168+            override fun applyManifestBatch(batch: DeviceManifestRegistryBatch) = true169+        }170+171+        val logs = capturePeachSyncLogs {172+            logRelayReconcileInventory(fakeDeviceStore)173+        }174+175+        assertEquals(176+            listOf(177+                Log.INFO to "cloud-relay: reconcile start — 2 paired device(s), 2 eligible",178+            ),179+            logs,180+        )181+    }182+142183     private data class KeyPair(val publicKey: ByteArray, val privateKey: ByteArray)143184 144185     private fun keys(): KeyPair {

view file