Skip to content

Commit

Permalink
Add a test to stress test SDK parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalzieu committed Aug 15, 2024
1 parent f6d2b2e commit 51acbaf
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,50 @@ test('can create new installation without breaking group', async () => {
return true
})

test('can create 10 groups in parallel', async () => {
const [client1, client2] = await createClients(2)
const groupsPromise: Promise<Group>[] = []

// Creating 9 groups in // works
for (let index = 0; index < 9; index++) {
groupsPromise.push(client1.conversations.newGroup([client2.address]))
}
console.log('Creating 9 groups...')
await Promise.race([
Promise.all(groupsPromise),
new Promise((_, reject) =>
setTimeout(
() =>
reject(
new Error(
'Creating 9 groups took more than 5 secons long to resolve'
)
),
5000
)
),
])
console.log('Created 9 groups')

// Creating 10 groups in // never resolves
for (let index = 0; index < 10; index++) {
groupsPromise.push(client1.conversations.newGroup([client2.address]))
}
console.log('Creating 10 groups...')
await Promise.race([
Promise.all(groupsPromise),
new Promise((_, reject) =>
setTimeout(
() => reject(new Error('Creating 9 groups worked but not 10 groups')),
5000
)
),
])
console.log('Created 10 groups')

return true
})

// Commenting this out so it doesn't block people, but nice to have?
// test('can stream messages for a long time', async () => {
// const bo = await Client.createRandom({ env: 'local', enableV3: true })
Expand Down

0 comments on commit 51acbaf

Please sign in to comment.