test(prefs): account for the Community List fragments slot

The new kind-33302 backup slot never existed in the legacy SharedPreferences
file, so it stays out of the one-shot migration table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PmuzkD5qdqgv6dMeRMoC5N
This commit is contained in:
Claude
2026-09-29 14:00:22 +00:00
parent 1350533850
commit 85b0497716
3 changed files with 8 additions and 5 deletions
@@ -41,6 +41,8 @@ import okio.IOException
*/
enum class LatestEventSlot(
val prefKey: String,
/** False for a slot added after the SharedPreferences era: there is nothing to migrate. */
val existedInLegacyPrefs: Boolean = true,
) {
CONTACT_LIST("latestContactList"),
USER_METADATA("latestUserMetadata"),
@@ -63,7 +65,7 @@ enum class LatestEventSlot(
CONCORD_LIST("latestConcordList"),
/** The kind-33302 Community List fragments (CORD-02 §8), one event JSON per line. */
CONCORD_LIST_FRAGMENTS("latestConcordListFragments"),
CONCORD_LIST_FRAGMENTS("latestConcordListFragments", existedInLegacyPrefs = false),
TRUST_PROVIDER_LIST("latestTrustProviderList"),
KEY_PACKAGE_RELAY_LIST("latestKeyPackageRelayList"),
FAVORITE_ALGO_FEEDS_LIST("latestFavoriteAlgoFeedsList"),
@@ -97,7 +99,7 @@ class LatestEventCacheStore(
val legacyTable =
LegacyKeyTable(
"migrated.latestEvents",
LatestEventSlot.entries.map { LegacyStringKey(it.prefKey, it.key) },
LatestEventSlot.entries.filter { it.existedInLegacyPrefs }.map { LegacyStringKey(it.prefKey, it.key) },
)
}
@@ -107,10 +107,11 @@ class LatestEventCacheStoreTest {
assertEquals("latestUserMetadata", LatestEventSlot.USER_METADATA.prefKey)
assertEquals("latestContactList", LatestEventSlot.CONTACT_LIST.prefKey)
assertEquals("latestNIP65RelayList", LatestEventSlot.NIP65_RELAY_LIST.prefKey)
assertEquals(26, LatestEventSlot.entries.size)
assertEquals("latestConcordListFragments", LatestEventSlot.CONCORD_LIST_FRAGMENTS.prefKey)
assertEquals(27, LatestEventSlot.entries.size)
assertEquals(
"prefKeys must be unique",
26,
27,
LatestEventSlot.entries
.map { it.prefKey }
.toSet()
@@ -209,7 +209,7 @@ class LegacyKeyTableTest {
)
assertEquals(FollowListSlot.entries.size, TopNavFollowListStore.legacyTable.keys.size)
assertEquals(LatestEventSlot.entries.size, LatestEventCacheStore.legacyTable.keys.size)
assertEquals(LatestEventSlot.entries.count { it.existedInLegacyPrefs }, LatestEventCacheStore.legacyTable.keys.size)
}
/** Several tables share one store, so their markers must not collide. */