Skip to content

Commit

Permalink
Update libxmtp - Fix pending commit clearing after invalid permissions (
Browse files Browse the repository at this point in the history
#254)

* Adds test for catching pending commit error after invalid commit

* Update libxmtp binaries and update tests

* lint fix

---------

Co-authored-by: cameronvoell <[email protected]>
  • Loading branch information
cameronvoell and cameronvoell authored Jun 11, 2024
1 parent 6f6b5a6 commit 71d9df5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ class GroupPermissionsTest {
assert(superAdminList.contains(boClient.inboxId))

// Verify that alix can NOT update group name
assert(boGroup.name == "New Group")
assert(boGroup.name == "")
val exception = assertThrows(uniffi.xmtpv3.GenericException.GroupException::class.java) {
runBlocking {
alixGroup.updateGroupName("Alix group name")
}
}
assertEquals(exception.message, "Group error: generic: failed to wait for intent")
assertEquals(exception.message, "Group error: generic: Group intent could not be committed")
runBlocking {
alixGroup.sync()
boGroup.sync()
}
assert(boGroup.name == "New Group")
assert(alixGroup.name == "New Group")
assert(boGroup.name == "")
assert(alixGroup.name == "")

runBlocking {
boGroup.addAdmin(alixClient.inboxId)
Expand Down Expand Up @@ -165,7 +165,7 @@ class GroupPermissionsTest {
alixGroup.updateGroupName("Alix group name 2")
}
}
assertEquals(exception.message, "Group error: generic: failed to wait for intent")
assertEquals(exception.message, "Group error: generic: Group intent could not be committed")
}

@Test
Expand Down Expand Up @@ -257,4 +257,35 @@ class GroupPermissionsTest {
assert(superAdmins.size == 2)
assert(regularMembers.isEmpty())
}

@Test
fun testCanCommitAfterInvalidPermissionsCommit() {
val boGroup = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress, caro.walletAddress), GroupPermissions.ALL_MEMBERS) }
runBlocking { alixClient.conversations.syncGroups() }
val alixGroup = runBlocking { alixClient.conversations.listGroups().first() }

// Verify that alix can NOT add an admin
assert(boGroup.name == "")
val exception = assertThrows(XMTPException::class.java) {
runBlocking {
alixGroup.addAdmin(alixClient.inboxId)
}
}
assertEquals(exception.message, "Permission denied: Unable to add admin")
runBlocking {
alixGroup.sync()
boGroup.sync()
}

// Verify that alix can update group name
runBlocking {
boGroup.sync()
alixGroup.sync()
alixGroup.updateGroupName("Alix group name")
alixGroup.sync()
boGroup.sync()
}
assert(boGroup.name == "Alix group name")
assert(alixGroup.name == "Alix group name")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class GroupTest {
fun testNameAGroup() {
val boGroup = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress)) }
runBlocking {
assertEquals("New Group", boGroup.name)
assertEquals("", boGroup.name)
boGroup.updateGroupName("This Is A Great Group")
boGroup.sync()
alixClient.conversations.syncGroups()
Expand Down
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 71d9df5

Please sign in to comment.