Skip to content

Commit

Permalink
get the tests all passing
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jan 26, 2024
1 parent 88e3456 commit d89f11c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 12 additions & 11 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,47 +47,48 @@ class GroupTest {

@Test
fun testCanCreateAGroup() {
val group = boClient.conversations.newGroup(listOf(alix.walletAddress))
val group = boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
assert(group.id.isNotEmpty())
}

@Test
fun testCanListGroupMembers() {
val group = boClient.conversations.newGroup(listOf(alix.walletAddress))
group.addMembers(listOf(caro.walletAddress))
assertSame(
group.memberAddresses(),
val group = boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
group.addMembers(listOf(caro.walletAddress.lowercase()))
assertEquals(
group.memberAddresses().sorted(),
listOf(
caro.walletAddress.lowercase(),
alix.walletAddress.lowercase(),
bo.walletAddress.lowercase()
)
).sorted()
)
}

@Test
fun testCanListGroups() {
boClient.conversations.newGroup(listOf(alix.walletAddress))
boClient.conversations.newGroup(listOf(caro.walletAddress))
boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
boClient.conversations.newGroup(listOf(caro.walletAddress.lowercase()))
val groups = boClient.conversations.listGroups()
assertEquals(groups.size, 2)
}

@Test
fun testCanListGroupsAndConversations() {
boClient.conversations.newGroup(listOf(alix.walletAddress))
boClient.conversations.newGroup(listOf(caro.walletAddress))
boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
boClient.conversations.newGroup(listOf(caro.walletAddress.lowercase()))
boClient.conversations.newConversation(alix.walletAddress)
val convos = boClient.conversations.list(includeGroups = true)
assertEquals(convos.size, 3)
}

@Test
fun testCanSendMessageToGroup() {
val group = boClient.conversations.newGroup(listOf(alix.walletAddress))
val group = boClient.conversations.newGroup(listOf(alix.walletAddress.lowercase()))
group.send("howdy")
group.send("gm")
runBlocking { group.sync() }
assertEquals(group.messages().last().body, "gm")
assertEquals(group.messages().size, 2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ data class Conversations(
return Group(client, group)
}

suspend fun syncGroups() {
libXMTPConversations?.sync()
}

fun listGroups(): List<Group> {
return runBlocking {
libXMTPConversations?.list(opts = FfiListConversationsOptions(null, null, null))?.map {
Expand Down

0 comments on commit d89f11c

Please sign in to comment.