Skip to content

test: integration tests for NIP-04 Encrypted Direct Messages (Kind 4) #506

@phoenix-server

Description

@phoenix-server

Summary

NIP-04 encrypted direct messages (kind 4) are listed in the relay's supported NIPs but have no integration test coverage. The flow differs from kind 1 in that messages are targeted to a recipient via a p tag, and access control (if any) hinges on that tag.

What to test

  • Alice publishes a kind 4 event with Bob's pubkey in a p tag → accepted and stored
  • Alice can retrieve her sent DM by event ID
  • Bob subscribes with a filter for #p matching his pubkey → receives Alice's DM
  • A third party (Charlie) subscribed to Bob's pubkey filter should not receive the encrypted content differently (relay stores and forwards the ciphertext as-is)
  • Duplicate kind 4 event submission → returns duplicate: command result

Relevant code

  • src/constants/base.tsEventKinds.ENCRYPTED_DIRECT_MESSAGE
  • src/handlers/event-strategies/default-event-strategy.ts

Suggested location

test/integration/features/nip-04/nip-04.feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    testUnit or integration test improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions