Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making fork repro test smaller #538

Conversation

cameronvoell
Copy link
Contributor

@cameronvoell cameronvoell commented Nov 18, 2024

test('groups cannot fork', async () => {
  const [alix, bo, new_one, new_two] = await createClients(4)
  // Create group with 2 users
  const alixGroup = await alix.conversations.newGroup([
    bo.address,
    new_one.address,
    new_two.address,
  ])

  // sync clients
  await alix.conversations.sync()
  await bo.conversations.sync()
  const boGroup: Group<DefaultContentTypes> = (await bo.conversations.findGroup(alixGroup.id))!

  // Remove two members in parallel
  // NB => if we don't use Promise.all but a loop, we don't get a fork
  console.log('*************libxmtp*********************: Removing members in parallel')
  await Promise.all([
    alixGroup.removeMembers([new_one.address]),
    alixGroup.removeMembers([new_two.address])
  ])

@cameronvoell
Copy link
Contributor Author

Test code here is causing a fork due to client processing their own message as an external message. Database locked is showing in the logs, likely cause

const [alix, bo, new_one, new_two] = await createClients(4)
// Create group with 2 users
const alixGroup = await alix.conversations.newGroup([
bo.address,
new_one.address,
new_two.address,
])
// sync clients
await alix.conversations.sync()
await bo.conversations.sync()
const boGroup: Group<DefaultContentTypes> = (await bo.conversations.findGroup(alixGroup.id))!
// Remove two members in parallel
// NB => if we don't use Promise.all but a loop, we don't get a fork
console.log('*************libxmtp*********************: Removing members in parallel')
const newClients = [new_one, new_two]
await Promise.all(
newClients.map((client) => {
console.log(`Removing member ${client.address}...`)
alixGroup.removeMembers([client.address])
})
)

@cameronvoell cameronvoell force-pushed the cv/adjustments/noe/fork-reproduction-test branch from b8c962b to 01e70d0 Compare November 19, 2024 18:09
@neekolas
Copy link
Contributor

A variation on this we'll want to test as well is what happens if the two removes happen in parallel, but are being done by different group members. That can happen in the real world as well (me and you both kick someone out of the group at the same time right after an installation was revoked)

@cameronvoell
Copy link
Contributor Author

Fixed in #569, test added to groupTests file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants