Skip to content

Commit

Permalink
add a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 3, 2024
1 parent a39b6c2 commit 420daee
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.xmtp.android.library

import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import app.cash.turbine.test
Expand Down Expand Up @@ -28,6 +29,9 @@ import org.xmtp.proto.mls.message.contents.TranscriptMessages
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.GroupPermissionPreconfiguration
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionOption
import java.security.SecureRandom
import java.util.Date
import kotlin.time.Duration.Companion.nanoseconds
import kotlin.time.DurationUnit

@RunWith(AndroidJUnit4::class)
class GroupTest {
Expand Down Expand Up @@ -545,6 +549,31 @@ class GroupTest {
assertEquals(sameGroup.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 2)
}

@Test
fun testCanListGroupMessagesAfter() {
val group = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress)) }
runBlocking {
group.send("howdy")
group.send("gm")
}
Thread.sleep(1000)
val time = Date()
assertEquals(group.messages().size, 3)
assertEquals(group.messages(after = time).size, 0)
runBlocking {
group.send("howdy")
group.send("gm")
}
assertEquals(group.messages().size, 5)
assertEquals(group.messages(after = time).size, 2)

runBlocking { alixClient.conversations.syncConversations() }
val sameGroup = runBlocking { alixClient.conversations.listGroups().last() }
runBlocking { sameGroup.sync() }
assertEquals(sameGroup.messages().size, 5)
assertEquals(sameGroup.messages(after = time).size, 2)
}

@Test
fun testCanSendContentTypesToGroup() {
Client.register(codec = ReactionCodec())
Expand Down

0 comments on commit 420daee

Please sign in to comment.