Skip to content

test: add NIP-04 integration coverage for encrypted direct messages #562

Draft
Priyanshubhartistm wants to merge 6 commits intocameri:mainfrom
Priyanshubhartistm:test/nip-04-integration-tests
Draft

test: add NIP-04 integration coverage for encrypted direct messages #562
Priyanshubhartistm wants to merge 6 commits intocameri:mainfrom
Priyanshubhartistm:test/nip-04-integration-tests

Conversation

@Priyanshubhartistm
Copy link
Copy Markdown
Collaborator

@Priyanshubhartistm Priyanshubhartistm commented Apr 22, 2026

Description

Adds integration test coverage for NIP-04 Encrypted Direct Messages (kind 4).

What was added

  • New feature file:
    • test/integration/features/nip-04/nip-04.feature
  • New step definitions:
    • test/integration/features/nip-04/nip-04.feature.ts

Covered scenarios

  1. Alice publishes a kind 4 event with Bob’s pubkey in p tag (accepted/stored).
  2. Alice retrieves her sent DM by event ID.
  3. Bob subscribes using #p filter with his pubkey and receives Alice’s DM.
  4. Charlie subscribed to the same #p filter receives the same ciphertext payload (relay forwards as-is).
  5. Duplicate submission of the same kind 4 event returns duplicate: command result.

Notes

  • Reused existing integration framework patterns (Cucumber/Gherkin + shared helpers).
  • Added deterministic handling for duplicate command-result assertion to avoid replay/race issues.
  • No relay/business logic was modified; this is test-only coverage.

Related Issue

Closes
#506

Motivation and Context

NIP-04 is listed as supported by the relay but had no integration test coverage.
This PR closes that gap and verifies the expected relay behavior for kind 4 DM storage, querying, tag-based subscription, and duplicate handling.

How Has This Been Tested?

  • npm run docker:integration:run -- npm run test:integration -- test/integration/features/nip-04/nip-04.feature
    • Result: 34 scenarios (34 passed), 200 steps (200 passed)
  • Commit hooks also ran successfully:
    • npm run lint
    • npm run build:check
    • npm run test:unit (489 passing)

Screenshots (if appropriate):

N/A

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

🦋 Changeset detected

Latest commit: 8df5e78

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

This PR includes changesets to release 1 package
Name Type
nostream Patch

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

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 22, 2026

Coverage Status

coverage: 74.929%. remained the same — Priyanshubhartistm:test/nip-04-integration-tests into cameri:main

@Priyanshubhartistm Priyanshubhartistm marked this pull request as draft April 22, 2026 01:58
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