Skip to content

Commit

Permalink
Fix forked group bug (#258)
Browse files Browse the repository at this point in the history
* try and reproduce in android directly

* get it reproing in android

* add a test for the codec

* more tests

* update the so files

* update the tests

* all new bindings
  • Loading branch information
nplasterer authored Jun 17, 2024
1 parent 0d9b911 commit f2b3a4c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
56 changes: 56 additions & 0 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.xmtp.android.library
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import app.cash.turbine.test
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.catch
Expand All @@ -23,6 +24,7 @@ import org.xmtp.android.library.codecs.Reaction
import org.xmtp.android.library.codecs.ReactionAction
import org.xmtp.android.library.codecs.ReactionCodec
import org.xmtp.android.library.codecs.ReactionSchema
import org.xmtp.android.library.codecs.id
import org.xmtp.android.library.messages.MessageDeliveryStatus
import org.xmtp.android.library.messages.PrivateKey
import org.xmtp.android.library.messages.PrivateKeyBuilder
Expand Down Expand Up @@ -432,6 +434,60 @@ class GroupTest {
assertEquals(boClient.contacts.consentList.groupState(group.id), ConsentState.ALLOWED)
}

@Test
fun testCanStreamAndUpdateNameWithoutForkingGroup() {
val firstMsgCheck = 2
val secondMsgCheck = 5
var messageCallbacks = 0

val job = CoroutineScope(Dispatchers.IO).launch {
try {
boClient.conversations.streamAllGroupMessages().collect { message ->
messageCallbacks++
}
} catch (e: Exception) {
}
}

val alixGroup = runBlocking { alixClient.conversations.newGroup(listOf(bo.walletAddress)) }

runBlocking {
alixGroup.send("hello1")
alixGroup.updateGroupName("hello")
boClient.conversations.syncGroups()
}

val boGroups = runBlocking { boClient.conversations.listGroups() }
assertEquals(boGroups.size, 1)
val boGroup = boGroups[0]
runBlocking {
boGroup.sync()
}

val boMessages1 = boGroup.messages()
assertEquals(boMessages1.size, firstMsgCheck)

runBlocking {
boGroup.send("hello2")
boGroup.send("hello3")
alixGroup.sync()
}
Thread.sleep(1000)
val alixMessages = alixGroup.messages()
assertEquals(alixMessages.size, secondMsgCheck)
runBlocking {
alixGroup.send("hello4")
boGroup.sync()
}

val boMessages2 = boGroup.messages()
assertEquals(boMessages2.size, secondMsgCheck)

Thread.sleep(1000)

assertEquals(4, messageCallbacks)
}

@Test
fun testCanSendMessageToGroup() {
val group = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress)) }
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 6d880763
Version: 68ac19c6
Branch: main
Date: 2024-06-13 06:20:50 +0000
Date: 2024-06-17 17:37:54 +0000
Binary file modified library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so
Binary file not shown.

0 comments on commit f2b3a4c

Please sign in to comment.