Skip to content

Commit

Permalink
Merge branch 'main' into np/frames-signer
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer authored Nov 19, 2024
2 parents d90e994 + c65b40c commit 2f9b43e
Show file tree
Hide file tree
Showing 23 changed files with 1,128 additions and 454 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,33 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Run build with Gradle Wrapper
run: ./gradlew build

- name: Tag version 3.0.0
run: |
git tag 3.0.0
git push origin 3.0.0
- name: Create a GitHub release for version 3.0.0
- 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
uses: ncipollo/release-action@v1
with:
tag: "3.0.0"
name: "Release 3.0.0"
body: "A XMTP MLS only SDK 3.0.0"

tag: ${{ steps.tag_version.outputs.new_version }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Gradle Publish
env:
RELEASE_VERSION: "3.0.0"
RELEASE_VERSION: ${{ steps.tag_version.outputs.new_version }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGN_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
SIGN_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
MAVEN_PROFILE_ID: ${{ secrets.MAVEN_PROFILE_ID }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class AttachmentTest {
)
}
val messages = runBlocking { aliceConversation.messages() }
assertEquals(messages.size, 2)
if (messages.size == 2) {
assertEquals(messages.size, 1)
if (messages.size == 1) {
val content: Attachment? = messages[0].content()
assertEquals("test.txt", content?.filename)
assertEquals("text/plain", content?.mimeType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.walletAddress
import uniffi.xmtpv3.GenericException
import java.security.SecureRandom
import java.util.concurrent.CompletableFuture
Expand Down Expand Up @@ -55,7 +56,7 @@ class ClientTest {
appContext = context,
dbEncryptionKey = key
)
val inboxId = runBlocking { Client.getOrCreateInboxId(options, fakeWallet.address) }
val inboxId = runBlocking { Client.getOrCreateInboxId(options.api, fakeWallet.address) }
val client = runBlocking {
Client().create(
account = fakeWallet,
Expand Down Expand Up @@ -98,7 +99,7 @@ class ClientTest {

runBlocking {
client.conversations.newGroup(listOf(client2.address))
client.conversations.syncConversations()
client.conversations.sync()
assertEquals(client.conversations.listGroups().size, 1)
}

Expand All @@ -116,7 +117,7 @@ class ClientTest {
)
}
runBlocking {
client.conversations.syncConversations()
client.conversations.sync()
assertEquals(client.conversations.listGroups().size, 0)
}
}
Expand Down Expand Up @@ -216,7 +217,7 @@ class ClientTest {

runBlocking {
boClient.conversations.newGroup(listOf(alixClient.address))
boClient.conversations.syncConversations()
boClient.conversations.sync()
}

runBlocking {
Expand Down Expand Up @@ -320,4 +321,17 @@ class ClientTest {
state = runBlocking { alixClient3.inboxState(true) }
assertEquals(state.installations.size, 1)
}

@Test
fun testsCanFindOthersInboxStates() {
val fixtures = fixtures()
val states = runBlocking {
fixtures.alixClient.inboxStatesForInboxIds(
true,
listOf(fixtures.boClient.inboxId, fixtures.caroClient.inboxId)
)
}
assertEquals(states.first().recoveryAddress.lowercase(), fixtures.bo.walletAddress.lowercase())
assertEquals(states.last().recoveryAddress.lowercase(), fixtures.caro.walletAddress.lowercase())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class CodecTest {
)
}
val messages = runBlocking { aliceConversation.messages() }
assertEquals(messages.size, 2)
if (messages.size == 2) {
assertEquals(messages.size, 1)
if (messages.size == 1) {
val content: Double? = messages[0].content()
assertEquals(3.14, content)
assertEquals("Error: This app does not support numbers.", messages[0].fallbackContent)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.xmtp.android.library

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -12,6 +13,7 @@ import org.junit.runner.RunWith
import org.xmtp.android.library.messages.PrivateKey
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.walletAddress
import java.security.SecureRandom

@RunWith(AndroidJUnit4::class)
class ConversationsTest {
Expand Down Expand Up @@ -61,7 +63,7 @@ class ConversationsTest {
assertEquals(runBlocking { boClient.conversations.listDms().size }, 1)
assertEquals(runBlocking { boClient.conversations.listGroups().size }, 1)

runBlocking { caroClient.conversations.syncConversations() }
runBlocking { caroClient.conversations.sync() }
assertEquals(
runBlocking { caroClient.conversations.list().size },
2
Expand Down Expand Up @@ -116,7 +118,7 @@ class ConversationsTest {
runBlocking { caroClient.conversations.newGroup(listOf(bo.walletAddress)) }
val conversation =
runBlocking { boClient.conversations.findOrCreateDm(caro.walletAddress) }
runBlocking { boClient.conversations.syncConversations() }
runBlocking { boClient.conversations.sync() }

val allMessages = mutableListOf<DecodedMessage>()

Expand Down Expand Up @@ -164,4 +166,72 @@ class ConversationsTest {
assertEquals(2, allMessages.size)
job.cancel()
}

@Test
fun testSyncConsent() {
val key = SecureRandom().generateSeed(32)
val context = InstrumentationRegistry.getInstrumentation().targetContext
val alixWallet = PrivateKeyBuilder()

val alixClient = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
appContext = context,
dbEncryptionKey = key
)
)
}
val dm = runBlocking { alixClient.conversations.findOrCreateDm(bo.walletAddress) }
runBlocking {
dm.updateConsentState(ConsentState.DENIED)
assertEquals(dm.consentState(), ConsentState.DENIED)
boClient.conversations.sync()
}
val boDm = runBlocking { boClient.findConversation(dm.id) }

val alixClient2 = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
appContext = context,
dbEncryptionKey = key,
dbDirectory = context.filesDir.absolutePath.toString()
)
)
}

val state = runBlocking { alixClient2.inboxState(true) }
assertEquals(state.installations.size, 2)

runBlocking {
boClient.conversations.sync()
boDm?.sync()
alixClient.conversations.sync()
alixClient2.conversations.sync()
alixClient2.syncConsent()
alixClient.conversations.syncAllConversations()
Thread.sleep(2000)
alixClient2.conversations.syncAllConversations()
Thread.sleep(2000)
val dm2 = alixClient2.findConversation(dm.id)!!
assertEquals(ConsentState.DENIED, dm2.consentState())
alixClient2.preferences.consentList.setConsentState(
listOf(
ConsentListEntry(
dm2.id,
EntryType.CONVERSATION_ID,
ConsentState.ALLOWED
)
)
)
assertEquals(
alixClient2.preferences.consentList.conversationState(dm2.id),
ConsentState.ALLOWED
)
assertEquals(dm2.consentState(), ConsentState.ALLOWED)
}
}
}
Loading

0 comments on commit 2f9b43e

Please sign in to comment.