Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 0.14.1 release to libxmtp c446f94 #336

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release XMTP Android Package
on:
push:
branches:
- release
- cv/0.14.1-patch-libxmtp-update-c446f94

jobs:
library:
Expand All @@ -22,21 +22,21 @@ jobs:
uses: gradle/actions/setup-gradle@v3
- name: Run build with Gradle Wrapper
run: ./gradlew build
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
release_branches: "release"
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
- name: Tag version 0.14.1-patch1
run: |
git tag 0.14.1-patch1
git push origin 0.14.1-patch1

- name: Create a GitHub release for version 0.14.1-patch
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_version }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
tag: "0.14.1-patch1"
name: "Release 0.14.1-patch1"
body: "Patch release for inboxId and group fixes 0.14.1-patch"

- name: Gradle Publish
env:
RELEASE_VERSION: ${{ steps.tag_version.outputs.new_version }}
RELEASE_VERSION: "0.14.1-patch1"
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGN_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.xmtp.android.library.libxmtp.PermissionLevel
import org.xmtp.android.library.messages.PrivateKey
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.walletAddress
import uniffi.xmtpv3.GroupPermissions
import uniffi.xmtpv3.FfiGroupPermissionsOptions

@RunWith(AndroidJUnit4::class)
class GroupPermissionsTest {
Expand Down Expand Up @@ -76,7 +76,7 @@ class GroupPermissionsTest {

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

Expand Down Expand Up @@ -170,7 +170,7 @@ class GroupPermissionsTest {

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

Expand Down Expand Up @@ -211,7 +211,7 @@ class GroupPermissionsTest {

@Test
fun testGroupMembersAndPermissionLevel() {
val group = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress, caro.walletAddress), GroupPermissions.ADMIN_ONLY) }
val group = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress, caro.walletAddress), FfiGroupPermissionsOptions.ADMIN_ONLY) }
runBlocking { alixClient.conversations.syncGroups() }
val alixGroup = runBlocking { alixClient.conversations.listGroups().first() }

Expand Down Expand Up @@ -260,7 +260,7 @@ class GroupPermissionsTest {

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

Expand Down
242 changes: 235 additions & 7 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.xmtp.android.library.messages.PrivateKey
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.walletAddress
import org.xmtp.proto.mls.message.contents.TranscriptMessages
import uniffi.xmtpv3.GroupPermissions
import uniffi.xmtpv3.FfiGroupPermissionsOptions

@RunWith(AndroidJUnit4::class)
class GroupTest {
Expand Down Expand Up @@ -63,6 +63,233 @@ class GroupTest {
caroClient = fixtures.caroClient
}

@Test
fun testCanCreateV3FromKeyBundleWithSigner() {
val keyBytes = byteArrayOf(
-23, 120, -58, 96, -102, 65, -124, 17, -124, 96, -6, 40, 103, 35, 125, 64,
-90, 83, -48, -32, -2, 44, -51, -29, -81, 49, -22, -127, 74, -4, -121, -111
)

// Create a V2 client
val bobWallet = PrivateKeyBuilder()
val bob = runBlocking {
Client().create(
account = bobWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = false,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

// Create a hybrid client
val alixWallet = PrivateKeyBuilder()
val alix = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
dbEncryptionKey = keyBytes,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

runBlocking {
alix.conversations.newConversation(bob.address)
val keyBundle = alix.privateKeyBundle
alix.deleteLocalDatabase()

// Create from key bundle a hybrid client
val alixKeyBundle = Client().buildFromBundle(
bundle = keyBundle,
account = alixWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
dbEncryptionKey = keyBytes,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)

assertEquals(alixKeyBundle.address, alixWallet.address)

val convos = alixKeyBundle.conversations.list()
assertEquals(1, convos.size)
}
}

@Test
fun testCanCreateFromKeyBundleWithSigner() {
val keyBytes = byteArrayOf(
-23, 120, -58, 96, -102, 65, -124, 17, -124, 96, -6, 40, 103, 35, 125, 64,
-90, 83, -48, -32, -2, 44, -51, -29, -81, 49, -22, -127, 74, -4, -121, -111
)

// Create a V2 client
val bobWallet = PrivateKeyBuilder()
val bob = runBlocking {
Client().create(
account = bobWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = false,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

// Create a V2 client
val alixWallet = PrivateKeyBuilder()
val alix = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = false,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

runBlocking {
alix.conversations.newConversation(bob.address)
val keyBundle = alix.privateKeyBundle

// Create from key bundle a hybrid client
val alixKeyBundle = Client().buildFromBundle(
bundle = keyBundle,
account = alixWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
dbEncryptionKey = keyBytes,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)

assertEquals(alixKeyBundle.address, alix.address)

val convos1 = alixKeyBundle.conversations.list()
val convos2 = alix.conversations.list()
assertEquals(convos1.size, convos2.size)
}
}

@Test
fun testCanCreateFromKeyBundleWithoutSigner() {
val keyBytes = byteArrayOf(
-23, 120, -58, 96, -102, 65, -124, 17, -124, 96, -6, 40, 103, 35, 125, 64,
-90, 83, -48, -32, -2, 44, -51, -29, -81, 49, -22, -127, 74, -4, -121, -111
)

// Create a V2 client
val bobWallet = PrivateKeyBuilder()
val bob = runBlocking {
Client().create(
account = bobWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = false,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

// Create a V2 client
val alixWallet = PrivateKeyBuilder()
val alix = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = false,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

runBlocking {
alix.conversations.newConversation(bob.address)
val keyBundle = alix.privateKeyBundle

// Create from key bundle a hybrid client without signer
val alixKeyBundle = Client().buildFromBundle(
bundle = keyBundle,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
dbEncryptionKey = keyBytes,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)

assertEquals(alixKeyBundle.address, alix.address)

val convos1 = alixKeyBundle.conversations.list()
val convos2 = alix.conversations.list()
assertEquals(convos1.size, convos2.size)
}
}

@Test
fun testCanCreateV3FromKeyBundleWithoutSignerShouldFail() {
val keyBytes = byteArrayOf(
-23, 120, -58, 96, -102, 65, -124, 17, -124, 96, -6, 40, 103, 35, 125, 64,
-90, 83, -48, -32, -2, 44, -51, -29, -81, 49, -22, -127, 74, -4, -121, -111
)

// Create a V2 client
val bobWallet = PrivateKeyBuilder()
val bob = runBlocking {
Client().create(
account = bobWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = false,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

// Create a hybrid client
val alixWallet = PrivateKeyBuilder()
val alix = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
dbEncryptionKey = keyBytes,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}

runBlocking {
alix.conversations.newConversation(bob.address)
val keyBundle = alix.privateKeyBundle
alix.deleteLocalDatabase()

// Create from key bundle a hybrid client without signer should throw an error
assertThrows(XMTPException::class.java) {
runBlocking {
Client().buildFromBundle(
bundle = keyBundle,
options = ClientOptions(
api = ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
dbEncryptionKey = keyBytes,
appContext = InstrumentationRegistry.getInstrumentation().targetContext
)
)
}
}
}
}

@Test
fun testCanCreateAGroupWithDefaultPermissions() {
val boGroup = runBlocking {
Expand Down Expand Up @@ -94,8 +321,8 @@ class GroupTest {
assertEquals(alixGroup.members().size, 3)
assertEquals(boGroup.members().size, 3)

assertEquals(boGroup.permissionLevel(), GroupPermissions.ALL_MEMBERS)
assertEquals(alixGroup.permissionLevel(), GroupPermissions.ALL_MEMBERS)
assertEquals(boGroup.permissionLevel(), FfiGroupPermissionsOptions.ALL_MEMBERS)
assertEquals(alixGroup.permissionLevel(), FfiGroupPermissionsOptions.ALL_MEMBERS)
assertEquals(boGroup.isAdmin(boClient.inboxId), true)
assertEquals(boGroup.isAdmin(alixClient.inboxId), false)
assertEquals(alixGroup.isAdmin(boClient.inboxId), true)
Expand All @@ -110,7 +337,7 @@ class GroupTest {
val boGroup = runBlocking {
boClient.conversations.newGroup(
listOf(alix.walletAddress),
permissions = GroupPermissions.ADMIN_ONLY
permissions = FfiGroupPermissionsOptions.ADMIN_ONLY
)
}
runBlocking { alixClient.conversations.syncGroups() }
Expand Down Expand Up @@ -152,8 +379,8 @@ class GroupTest {
assertEquals(alixGroup.members().size, 2)
assertEquals(boGroup.members().size, 2)

assertEquals(boGroup.permissionLevel(), GroupPermissions.ADMIN_ONLY)
assertEquals(alixGroup.permissionLevel(), GroupPermissions.ADMIN_ONLY)
assertEquals(boGroup.permissionLevel(), FfiGroupPermissionsOptions.ADMIN_ONLY)
assertEquals(alixGroup.permissionLevel(), FfiGroupPermissionsOptions.ADMIN_ONLY)
assertEquals(boGroup.isAdmin(boClient.inboxId), true)
assertEquals(boGroup.isAdmin(alixClient.inboxId), false)
assertEquals(alixGroup.isAdmin(boClient.inboxId), true)
Expand Down Expand Up @@ -749,7 +976,8 @@ class GroupTest {
.collect { message ->
allMessages.add(message.topic)
}
} catch (e: Exception) {}
} catch (e: Exception) {
}
}
Thread.sleep(2500)

Expand Down
6 changes: 3 additions & 3 deletions library/src/main/java/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: feb48641
Branch: main
Date: 2024-06-26 22:31:21 +0000
Version: c446f94d
Branch: HEAD
Date: 2024-09-09 14:36:53 +0000
Loading