Skip to content

test(relay): signal invite mint await instead of yield polling (#991) - #1023

Merged
cameri merged 2 commits into
rewrite/mainfrom
test/close-during-mint-signal
Nov 1, 2026
Merged

cameri merged 2 commits into
rewrite/mainfrom
test/close-during-mint-signal

Conversation

@chappie-daemon

Copy link
Copy Markdown
Collaborator

Contributed by @avantikonde, who wrote this fix and reported it on #991. The commit is cherry-picked with -x from theirs, so authorship is preserved rather than reassigned:

What it changes

a_close_during_the_invite_mint_leaves_the_event_but_not_the_read waited for the invite mint with a 100-iteration yield_now() loop. On a loaded runner the loop can be exhausted before the mint task runs, and the test then fails with a message that accuses the mint. InMemoryInviteCodeRepository now carries a tokio::sync::Notify that fires when a create call starts, including one a gate is holding, and the test awaits it instead. Notify stores a permit when nothing is waiting, so a create that starts before the await still satisfies it.

The two comment blocks explain why the test authenticates before subscribing (the mint sits behind the NIP-42 identity check) and why a wire test cannot assert this after #978, where CLOSE runs as a connection-loop prefix.

Test-only: no production code path changes.

Verification

Built and run at the contributed commit on top of the current rewrite/main tip:

cargo test -p nostream-relay --test handlers a_close_during_the_invite_mint
test a_close_during_the_invite_mint_leaves_the_event_but_not_the_read ... ok
test result: ok. 1 passed; 0 failed; 51 filtered out

Closes #991.

@changeset-bot

changeset-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 453d057

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e64f46cf-0be7-4b55-932a-457069693d36

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

The PR replaces yield polling with a notification when invite creation starts.

  • The invite-mint test waits for a start signal before closing the subscription.

Reviews (2) · Last reviewed commit: "fix(relay): format the new import, and b..." · Reviewed by Greptile

Comment thread crates/nostream-relay/src/testing.rs Resolved
Comment thread crates/nostream-relay/tests/handlers.rs Resolved
Two review findings from Greptile on the contributed change, neither about the
fix itself:

- `cargo fmt --all --check` failed: `use tokio::sync::Notify` sat inside the
  futures import group, before the `nostream_config` block, so the required
  format step would have stopped the checks before the test ran.
- `create_started().await` had no deadline, so a handler that panicked before
  minting would hang the test instead of failing it. The wait is now wrapped in
  a five-second timeout with a message that says which wait expired.

`cargo fmt --all --check` is clean, and
`cargo test -p nostream-relay --test handlers a_close_during_the_invite_mint`
passes.
@cameri
cameri merged commit 48f1e01 into rewrite/main Nov 1, 2026
16 checks passed
@cameri
cameri deleted the test/close-during-mint-signal branch November 1, 2026 14:36
@chappie-daemon

Copy link
Copy Markdown
Collaborator Author

Merged as 48f1e01 — thanks, @avantikonde. The Notify signal is the right shape: it fires from create itself rather than asking the scheduler for permission to run, and because a permit is stored when nobody is waiting, a create that starts before the await still satisfies it. That removes the one way this test could accuse the mint of a defect it did not have.

Two review findings landed on top in 453d057 before the merge, neither of them about your fix: cargo fmt --all --check was failing because use tokio::sync::Notify sat inside the futures_util group, and the new wait had no deadline, so it is now wrapped in a five-second tokio::time::timeout — a handler that dies before minting fails the test with a message instead of hanging.

Your commit is the first on the branch with your authorship intact, and your branch is linked from the PR. Thanks for the careful write-up on the issue too.

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.

3 participants