From 420daee5f50d2ea3952daaeb84e7b2a458043f62 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Sun, 3 Nov 2024 14:09:46 -0800 Subject: [PATCH] add a test for it --- .../org/xmtp/android/library/GroupTest.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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 09679804b..da6294e21 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt @@ -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 @@ -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 { @@ -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())