Skip to content

Commit

Permalink
make sure working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 8, 2024
1 parent 3680bda commit 39f6181
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
99 changes: 53 additions & 46 deletions example/src/tests/groupPerformanceTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -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
})
2 changes: 1 addition & 1 deletion ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 39f6181

Please sign in to comment.