From 39f61813cc4a56ae14353e43510354db81a105c8 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 7 Oct 2024 23:15:10 -0600 Subject: [PATCH] make sure working as expected --- .../wrappers/GroupWrapper.kt | 1 + example/src/tests/groupPerformanceTests.ts | 99 ++++++++++--------- ios/XMTPModule.swift | 2 +- 3 files changed, 55 insertions(+), 47 deletions(-) diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/GroupWrapper.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/GroupWrapper.kt index 4310d769..9cbc679f 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/GroupWrapper.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/GroupWrapper.kt @@ -70,6 +70,7 @@ class GroupParamsWrapper( ) { companion object { fun groupParamsFromJson(groupParams: String): GroupParamsWrapper { + if (groupParams.isEmpty()) return GroupParamsWrapper() val jsonOptions = JsonParser.parseString(groupParams).asJsonObject return GroupParamsWrapper( if (jsonOptions.has("members")) jsonOptions.get("members").asBoolean else true, diff --git a/example/src/tests/groupPerformanceTests.ts b/example/src/tests/groupPerformanceTests.ts index 088c089b..fac5d100 100644 --- a/example/src/tests/groupPerformanceTests.ts +++ b/example/src/tests/groupPerformanceTests.ts @@ -224,59 +224,21 @@ test('testing large member listings', async () => { return true }) -test('testing sending message in large group', async () => { - await beforeAll(1, 2000, 100) - - const alixGroup = initialGroups[0] - let start = Date.now() - await alixGroup.send({ text: `Alix message` }) - let end = Date.now() - console.log(`Alix sent a message in ${end - start}ms`) - assert( - end - start < 200, - 'sending a message should take less than a .2 second' - ) - - await boClient.conversations.syncGroups() - const boGroup = await boClient.conversations.findGroup(alixGroup.id) - start = Date.now() - await boGroup!.prepareMessage({ text: `Bo message` }) - end = Date.now() - console.log(`Bo sent a message in ${end - start}ms`) - assert( - end - start < 100, - 'preparing a message should take less than a .1 second' - ) - - start = Date.now() - await boGroup!.sync() - end = Date.now() - console.log(`Bo synced messages in ${end - start}ms`) - assert( - end - start < 9000, - 'syncing 2000 messages should take less than a 9 second' - ) - - start = Date.now() - await boGroup!.send({ text: `Bo message 2` }) - end = Date.now() - console.log(`Bo sent a message in ${end - start}ms`) - assert( - end - start < 100, - 'sending a message should take less than a .1 second' - ) - - return true -}) - test('testing large group listings with ordering', async () => { - await beforeAll(1000, 1, 20) + await beforeAll(1000, 10, 10) let start = Date.now() let groups = await alixClient.conversations.listGroups() let end = Date.now() console.log(`Alix loaded ${groups.length} groups in ${end - start}ms`) + await groups[5].send({ text: `Alix message` }) + await groups[50].send({ text: `Alix message` }) + await groups[150].send({ text: `Alix message` }) + await groups[500].send({ text: `Alix message` }) + await groups[700].send({ text: `Alix message` }) + await groups[900].send({ text: `Alix message` }) + let start2 = Date.now() let groups2 = await alixClient.conversations.listGroups( { @@ -338,3 +300,48 @@ test('testing large group listings with ordering', async () => { return true }) + +test('testing sending message in large group', async () => { + await beforeAll(1, 2000, 100) + + const alixGroup = initialGroups[0] + let start = Date.now() + await alixGroup.send({ text: `Alix message` }) + let end = Date.now() + console.log(`Alix sent a message in ${end - start}ms`) + assert( + end - start < 200, + 'sending a message should take less than a .2 second' + ) + + await boClient.conversations.syncGroups() + const boGroup = await boClient.conversations.findGroup(alixGroup.id) + start = Date.now() + await boGroup!.prepareMessage({ text: `Bo message` }) + end = Date.now() + console.log(`Bo sent a message in ${end - start}ms`) + assert( + end - start < 100, + 'preparing a message should take less than a .1 second' + ) + + start = Date.now() + await boGroup!.sync() + end = Date.now() + console.log(`Bo synced messages in ${end - start}ms`) + assert( + end - start < 9000, + 'syncing 2000 messages should take less than a 9 second' + ) + + start = Date.now() + await boGroup!.send({ text: `Bo message 2` }) + end = Date.now() + console.log(`Bo sent a message in ${end - start}ms`) + assert( + end - start < 100, + 'sending a message should take less than a .1 second' + ) + + return true +}) diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 79689035..ecaeb5d8 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -568,7 +568,7 @@ public class XMTPModule: Module { var results: [String] = [] for group in groupList { await self.groupsManager.set(group.cacheKey(inboxId), group) - let encodedGroup = try await GroupWrapper.encode(group, client: client) + let encodedGroup = try await GroupWrapper.encode(group, client: client, groupParams: params) results.append(encodedGroup) } return results