Remove cruft around SignalAccountRecord.

This commit is contained in:
Greyson Parrelli
2024-11-11 11:01:34 -05:00
parent 5e8318d63f
commit ae37c4019f
30 changed files with 536 additions and 1523 deletions

View File

@@ -0,0 +1,58 @@
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.storage
import junit.framework.TestCase.assertEquals
import okio.ByteString
import okio.ByteString.Companion.toByteString
import org.junit.Test
import org.thoughtcrime.securesms.util.Util
import org.whispersystems.signalservice.api.storage.SignalAccountRecord
import org.whispersystems.signalservice.api.storage.SignalContactRecord
import org.whispersystems.signalservice.api.storage.StorageId
import org.whispersystems.signalservice.internal.storage.protos.AccountRecord
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord
class StorageRecordTest {
@Test
fun `describeDiff - general test`() {
val a = SignalAccountRecord(
StorageId.forAccount(Util.getSecretBytes(16)),
AccountRecord(
profileKey = ByteString.EMPTY,
givenName = "First",
familyName = "Last"
)
)
val b = SignalAccountRecord(
StorageId.forAccount(Util.getSecretBytes(16)),
AccountRecord(
profileKey = Util.getSecretBytes(16).toByteString(),
givenName = "First",
familyName = "LastB"
)
)
assertEquals("Some fields differ: familyName, id, profileKey", a.describeDiff(b))
}
@Test
fun `describeDiff - different class`() {
val a = SignalAccountRecord(
StorageId.forAccount(Util.getSecretBytes(16)),
AccountRecord()
)
val b = SignalContactRecord(
StorageId.forAccount(Util.getSecretBytes(16)),
ContactRecord()
)
assertEquals("Classes are different!", a.describeDiff(b))
}
}

View File

@@ -180,7 +180,7 @@ public final class StorageSyncHelperTest {
.setProfileGivenName(profileName);
}
private static <E extends SignalRecord> StorageRecordUpdate<E> update(E oldRecord, E newRecord) {
private static <E extends SignalRecord<?>> StorageRecordUpdate<E> update(E oldRecord, E newRecord) {
return new StorageRecordUpdate<>(oldRecord, newRecord);
}