Skip to content

Commit

Permalink
get all the tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 15, 2024
1 parent 3ac07b0 commit 2682b6b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 23 deletions.
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 @@ -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
Expand Up @@ -209,10 +209,15 @@ class ConversationsTest {
runBlocking {
boClient.conversations.sync()
boDm?.sync()
alixClient.conversations.sync()
alixClient2.conversations.sync()
val dm2 = alixClient2.findConversation(dm.id)!!
alixClient2.syncConsent()
assertEquals(dm2.consentState(), ConsentState.DENIED)
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(
Expand Down
12 changes: 6 additions & 6 deletions library/src/androidTest/java/org/xmtp/android/library/DmTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class DmTest {
assertEquals(dm.messages().first().body, "gm")
assertEquals(dm.messages().first().id, messageId)
assertEquals(dm.messages().first().deliveryStatus, MessageDeliveryStatus.PUBLISHED)
assertEquals(dm.messages().size, 3)
assertEquals(dm.messages().size, 2)

runBlocking { alixClient.conversations.sync() }
val sameDm = runBlocking { alixClient.conversations.listDms().last() }
Expand All @@ -215,12 +215,12 @@ class DmTest {
dm.send("gm")
}

assertEquals(dm.messages().size, 3)
assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 3)
assertEquals(dm.messages().size, 2)
assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 2)
runBlocking { dm.sync() }
assertEquals(dm.messages().size, 3)
assertEquals(dm.messages().size, 2)
assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.UNPUBLISHED).size, 0)
assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 3)
assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 2)

runBlocking { alixClient.conversations.sync() }
val sameDm = runBlocking { alixClient.conversations.listDms().last() }
Expand Down Expand Up @@ -253,7 +253,7 @@ class DmTest {
runBlocking { dm.sync() }

val messages = dm.messages()
assertEquals(messages.size, 3)
assertEquals(messages.size, 2)
val content: Reaction? = messages.first().content()
assertEquals("U+1F603", content?.content)
assertEquals(messageToReact.id, content?.reference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class ReactionTest {
)
}
val messages = runBlocking { aliceConversation.messages() }
assertEquals(messages.size, 3)
if (messages.size == 3) {
assertEquals(messages.size, 2)
if (messages.size == 2) {
val content: Reaction? = messages.first().content()
assertEquals("U+1F603", content?.content)
assertEquals(messageToReact.id, content?.reference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class ReadReceiptTest {
)
}
val messages = runBlocking { aliceConversation.messages() }
assertEquals(messages.size, 3)
if (messages.size == 3) {
assertEquals(messages.size, 2)
if (messages.size == 2) {
val contentType: String = messages.first().encodedContent.type.typeId
assertEquals(contentType, "readReceipt")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class ReplyTest {
)
}
val messages = runBlocking { aliceConversation.messages() }
assertEquals(messages.size, 3)
if (messages.size == 3) {
assertEquals(messages.size, 2)
if (messages.size == 2) {
val content: Reply? = messages.first().content()
assertEquals("Hello", content?.content)
assertEquals(messageToReact.id, content?.reference)
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/org/xmtp/android/library/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data class ClientOptions(
val dbEncryptionKey: ByteArray,
val historySyncUrl: String = when (api.env) {
XMTPEnvironment.PRODUCTION -> "https://message-history.production.ephemera.network/"
XMTPEnvironment.LOCAL -> "http://0.0.0.0:5558"
XMTPEnvironment.LOCAL -> "http://10.0.2.2:5558"
else -> "https://message-history.dev.ephemera.network/"
},
val dbDirectory: String? = null,
Expand Down Expand Up @@ -64,10 +64,10 @@ class Client() {
logger = XMTPLogger(),
host = environment.env.getUrl(),
isSecure = environment.isSecure,
accountAddress = address
accountAddress = address.lowercase()
)
if (inboxId.isNullOrBlank()) {
inboxId = generateInboxId(address, 0.toULong())
inboxId = generateInboxId(address.lowercase(), 0.toULong())
}
return inboxId
}
Expand All @@ -85,7 +85,7 @@ class Client() {
inboxId: String,
environment: XMTPEnvironment,
) : this() {
this.address = address
this.address = address.lowercase()
this.preferences = PrivatePreferences(client = this, ffiClient = libXMTPClient)
this.ffiClient = libXMTPClient
this.conversations =
Expand Down Expand Up @@ -170,7 +170,7 @@ class Client() {
isSecure = options.api.isSecure,
db = dbPath,
encryptionKey = options.dbEncryptionKey,
accountAddress = accountAddress,
accountAddress = accountAddress.lowercase(),
inboxId = inboxId,
nonce = 0.toULong(),
legacySignedPrivateKeyProto = null,
Expand Down

0 comments on commit 2682b6b

Please sign in to comment.