-
Notifications
You must be signed in to change notification settings - Fork 231
test(integration): add NIP-62 vanish tests and fix test enviroment #537
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
Merged
cameri
merged 7 commits into
cameri:main
from
vikashsiwach:test/nip62-vanish-integration
Apr 19, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
92caa3f
test(integration): add NIP-62 vanish tests and fix test enviroment
vikashsiwach 1cec575
Merge branch 'main' into test/nip62-vanish-integration
vikashsiwach 42d9e81
Merge branch 'main' into test/nip62-vanish-integration
vikashsiwach cf4b68d
fix(redis-adapter): replace leftover debug calls with logger
vikashsiwach 6d12777
Merge branch 'main' into test/nip62-vanish-integration
vikashsiwach 035f8b2
test(integration): improve NIP-62 assertions
vikashsiwach 0a03738
Merge branch 'main' into test/nip62-vanish-integration
vikashsiwach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "nostream": patch | ||
| --- | ||
|
|
||
| Add NIP-62 integration tests for Request to Vanish |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| Feature: NIP-62 | ||
| Scenario: Alice requests to vanish | ||
| Given someone called Alice | ||
| And someone called Bob | ||
| And Alice sends a set_metadata event | ||
| And Alice sends a text_note event with content "please forget this" | ||
| When Alice sends a request_to_vanish event | ||
| And Bob subscribes to author Alice | ||
| Then Bob receives 1 request_to_vanish event from Alice and EOSE | ||
|
|
||
| Scenario: Alice cannot publish after requesting to vanish | ||
| Given someone called Alice | ||
| When Alice sends a request_to_vanish event | ||
| And Alice drafts a text_note event with content "I should be blocked" | ||
| Then Alice sends their last draft event unsuccessfully because "blocked: request to vanish active for pubkey" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { Then, When } from '@cucumber/cucumber' | ||
| import { expect } from 'chai' | ||
| import WebSocket from 'ws' | ||
|
|
||
| import { createEvent, sendEvent, waitForEventCount } from '../helpers' | ||
| import { ALL_RELAYS, EventKinds, EventTags } from '../../../../src/constants/base' | ||
| import { Event } from '../../../../src/@types/event' | ||
| import { isDraft } from '../shared' | ||
|
|
||
| When(/^(\w+) sends a request_to_vanish event$/, async function (name: string) { | ||
| const ws = this.parameters.clients[name] as WebSocket | ||
| const { pubkey, privkey } = this.parameters.identities[name] | ||
|
|
||
| const event: Event = await createEvent( | ||
| { pubkey, kind: EventKinds.REQUEST_TO_VANISH, content: '', tags: [[EventTags.Relay, ALL_RELAYS]] }, | ||
| privkey, | ||
| ) | ||
|
|
||
| await sendEvent(ws, event) | ||
| this.parameters.events[name].push(event) | ||
| }) | ||
|
|
||
| Then( | ||
| /(\w+) receives (\d+) request_to_vanish events? from (\w+) and EOSE$/, | ||
| async function (name: string, count: string, author: string) { | ||
| const ws = this.parameters.clients[name] as WebSocket | ||
| const subscription = this.parameters.subscriptions[name][this.parameters.subscriptions[name].length - 1] | ||
| const expectedCount = Number(count) | ||
| const expectedPubkey = this.parameters.identities[author].pubkey | ||
| const events = await waitForEventCount(ws, subscription.name, expectedCount, true) | ||
|
|
||
| expect(events.length).to.equal(expectedCount) | ||
| for (const event of events) { | ||
| expect(event.kind).to.equal(EventKinds.REQUEST_TO_VANISH) | ||
| expect(event.pubkey).to.equal(expectedPubkey) | ||
| } | ||
| }, | ||
| ) | ||
|
|
||
| Then( | ||
| /^(\w+) sends their last draft event unsuccessfully because "([^"]+)"$/, | ||
| async function (name: string, reason: string) { | ||
| const ws = this.parameters.clients[name] as WebSocket | ||
| const event = this.parameters.events[name].findLast((event: Event) => event[isDraft]) | ||
|
|
||
| if (!event) { | ||
| throw new Error(`No draft event found for ${name}`) | ||
| } | ||
|
|
||
| delete event[isDraft] | ||
|
|
||
| const command = await sendEvent(ws, event, false) | ||
| expect(command[1]).to.equal(event.id) | ||
| expect(command[2]).to.be.false | ||
| expect(command[3]).to.equal(reason) | ||
| }, | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findLast(...)can returnundefinedif no draft event exists;delete event[isDraft]would then throw and fail the scenario with a non-actionable error. Add an explicit assertion/guard that a draft event was found before mutating/sending it.