From 5827b9e1677bd3b982e83da5215eb440ce1c260e Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Sep 2024 22:24:13 -0600 Subject: [PATCH] fix up and write tests --- .../androidTest/java/org/xmtp/android/library/ClientTest.kt | 5 +++-- .../androidTest/java/org/xmtp/android/library/GroupTest.kt | 2 +- .../java/org/xmtp/android/library/GroupUpdatedTest.kt | 6 +++--- .../java/org/xmtp/android/library/V3ClientTest.kt | 2 +- .../src/main/java/org/xmtp/android/library/Conversation.kt | 2 +- .../java/org/xmtp/android/library/libxmtp/Installation.kt | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt index 7adc83892..a1c7655f6 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt @@ -509,13 +509,14 @@ class ClientTest { } var state = runBlocking { alixClient3.inboxState(true) } - assertEquals(state.installationIds.size, 3) + assertEquals(state.installations.size, 3) + assert(state.installations.first().createdAt != null) runBlocking { alixClient3.revokeAllOtherInstallations(alixWallet) } state = runBlocking { alixClient3.inboxState(true) } - assertEquals(state.installationIds.size, 1) + assertEquals(state.installations.size, 1) } } diff --git a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt index 58b6c5423..1fca7ccd2 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt @@ -192,7 +192,7 @@ class GroupTest { ) assertEquals( - Conversation.Group(group).peerAddresses.sorted(), + Conversation.Group(group).peerAddresses().sorted(), listOf( caroClient.inboxId, alixClient.inboxId, diff --git a/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt b/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt index 15938fc04..2bedbeb63 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt @@ -89,11 +89,11 @@ class GroupUpdatedTest { } val messages = group.messages() assertEquals(messages.size, 1) - assertEquals(group.members().size, 3) + assertEquals(runBlocking { group.members().size }, 3) runBlocking { group.removeMembers(listOf(caro.walletAddress)) } val updatedMessages = group.messages() assertEquals(updatedMessages.size, 2) - assertEquals(group.members().size, 2) + assertEquals(runBlocking { group.members().size }, 2) val content: GroupUpdated? = updatedMessages.first().content() assertEquals( @@ -119,7 +119,7 @@ class GroupUpdatedTest { } val messages = group.messages() assertEquals(messages.size, 1) - assertEquals(group.members().size, 3) + assertEquals(runBlocking { group.members().size }, 3) runBlocking { group.send( content = membershipChange, diff --git a/library/src/androidTest/java/org/xmtp/android/library/V3ClientTest.kt b/library/src/androidTest/java/org/xmtp/android/library/V3ClientTest.kt index 8b63f59a2..f260d4968 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/V3ClientTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/V3ClientTest.kt @@ -82,7 +82,7 @@ class V3ClientTest { fun testsCanCreateGroup() { val group = runBlocking { boV3Client.conversations.newGroup(listOf(caroV2V3.walletAddress)) } assertEquals( - group.members().map { it.inboxId }.sorted(), + runBlocking { group.members().map { it.inboxId }.sorted() }, listOf(caroV2V3Client.inboxId, boV3Client.inboxId).sorted() ) diff --git a/library/src/main/java/org/xmtp/android/library/Conversation.kt b/library/src/main/java/org/xmtp/android/library/Conversation.kt index 00294cc8e..fdfad97e8 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversation.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversation.kt @@ -102,7 +102,7 @@ sealed class Conversation { * @return [TopicData] that contains all the information about the Topic, the conversation * context and the necessary encryption data for it. */ - suspend fun toTopicData(): TopicData { + fun toTopicData(): TopicData { val data = TopicData.newBuilder() .setCreatedNs(createdAt.time * 1_000_000) .setPeerAddress(peerAddress) diff --git a/library/src/main/java/org/xmtp/android/library/libxmtp/Installation.kt b/library/src/main/java/org/xmtp/android/library/libxmtp/Installation.kt index cd3814b43..8eeb767c9 100644 --- a/library/src/main/java/org/xmtp/android/library/libxmtp/Installation.kt +++ b/library/src/main/java/org/xmtp/android/library/libxmtp/Installation.kt @@ -11,4 +11,4 @@ class Installation(private val ffiInstallation: FfiInstallation) { get() = ffiInstallation.clientTimestampNs?.let { Date(it.toLong()) } -} \ No newline at end of file +}