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

test: be more exact when waiting for peers #866

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

EvanHahn
Copy link
Contributor

waitForPeers, a test helper, currently checks that the number of connected peers is expected. This has two problems:

  • If the number of connected peers is more than needed, it will never resolve.
  • If the number of connected peers is correct but the actual peers are different, the promise could resolve prematurely.

This snippet highlights the problem:

const managers = await createManagers(3, t)
const [a, b, c] = managers

connectPeers(managers)

await waitForPeers([a, c])

I think this is a useful change on its own, but will also make an upcoming change easier.

`waitForPeers`, a test helper, currently checks that the *number* of
connected peers is expected. This has two problems:

- If the number of connected peers is *more than needed*, it will never
  resolve.
- If the *number* of connected peers is correct but the actual peers are
  different, the promise could resolve prematurely.

This snippet highlights the problem:

```javascript
const managers = await createManagers(3, t)
const [a, b, c] = managers

connectPeers(managers)

await waitForPeers([a, c])
```

I think this is a useful change on its own, but will also make [an
upcoming change][0] easier.

[0]: #865
@EvanHahn EvanHahn merged commit 756c847 into main Sep 25, 2024
6 checks passed
@EvanHahn EvanHahn deleted the more-exact-waitforpeers branch September 25, 2024 14:57
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