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

Refactor client spec to remove sleep statements #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

raucao
Copy link
Contributor

@raucao raucao commented Sep 25, 2024

Instead of using random sleep values, add a wait_for helper method, which efficiently waits until async operations have changed the expected variables before running the assertions.

There was one spec, which would occasionally fail with the arbitrary sleep value, and which works reliably now. And because the sleep value for the wait_for loop is much lower, the specs are also considerably faster now.

closes #5

Instead of using random sleep values, add a `wait_for` helper method,
which efficiently waits until async operations have changed the expected
variables before running the assertions.

closes wilsonsilva#5
Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nostr ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 2:11pm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors the asynchronous test suite for the Nostr::Client by replacing arbitrary sleep statements with a more reliable wait_for helper method.

  • Removes sleep statements throughout the spec.
  • Introduces a wait_for helper to actively wait for desired conditions before assertions.

Reviewed Changes

File Description
spec/nostr/client_spec.rb Replaces sleeps with wait_for for better async operation tests.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

spec/nostr/client_spec.rb:315

  • [nitpick] Consider storing the result of block.call in a variable before the conditional check to avoid evaluating the block twice, which could lead to unintended side effects if the block has stateful behavior.
raise 'Condition not met within timeout' unless block.call
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.

remove sleep statements from test suite
1 participant