Skip to content

test: add NIP-40 standalone expiration integration coverage#528

Merged
cameri merged 11 commits intocameri:mainfrom
Priyanshubhartistm:test/nip-40-event-expiration
Apr 21, 2026
Merged

test: add NIP-40 standalone expiration integration coverage#528
cameri merged 11 commits intocameri:mainfrom
Priyanshubhartistm:test/nip-40-event-expiration

Conversation

@Priyanshubhartistm
Copy link
Copy Markdown
Collaborator

Description

  • Added NIP-40 standalone Gherkin scenarios in test/integration/features/nip-40/nip-40.feature.
  • Added step definitions in test/integration/features/nip-40/nip-40.feature.ts.
  • Scenario coverage added exactly as requested:
    • Kind 1 event with past expiration is not returned via REQ.
    • Kind 1 event with future expiration is returned via REQ.
    • Kind 1 event that expires after storage is not served to new subscribers.
  • Step definitions use EventTags.Expiration and EventExpirationTimeMetadataKey from src/constants/base.ts.
  • Added minimal test helper support in test/integration/features/helpers.ts to publish events without forcing expected OK success, so expiration edge cases can be asserted cleanly.
  • Scope is test-only for this PR.

Related Issue

Motivation and Context

  • NIP-33 already validates expiration behavior for parameterized replaceable events.
  • There was no integration coverage for ordinary standalone events like kind 1 text notes.
  • This closes that gap and codifies expected relay behavior for NIP-40 on non-replaceable events.

How Has This Been Tested?

  • Local pre-commit hook pipeline executed successfully:
    • lint
    • build:check
    • unit tests
  • Integration suite command run:
    • npm run docker:test:integration -- test/integration/features/nip-40/nip-40.feature
  • Observed behavior:
    • Scenario 1 passed.
    • Scenario 2 passed.
    • Scenario 3 currently fails against existing relay implementation, which is expected for a test-only PR that captures issue behavior.

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.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 19, 2026

Coverage Status

coverage: 74.483% (+0.1%) from 74.365% — Priyanshubhartistm:test/nip-40-event-expiration into cameri:main

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds standalone (kind 1 / text_note) NIP-40 expiration integration coverage to complement existing NIP-33 expiration tests, plus a small integration-test helper refactor to allow asserting rejected publishes.

Changes:

  • Added Gherkin scenarios for expired-in-past, expires-in-future, and post-storage-expiration behavior for kind 1 events.
  • Added Cucumber step definitions for publishing expiring text_note events, waiting for expiration, subscribing, and asserting EOSE + counts.
  • Added a lower-level publishEvent helper to observe OK results without forcing expected success, and reimplemented sendEvent on top.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/integration/features/nip-40/nip-40.feature Adds NIP-40 standalone expiration scenarios for kind 1 events.
test/integration/features/nip-40/nip-40.feature.ts Implements the step definitions to publish expiring events and assert subscription results.
test/integration/features/helpers.ts Introduces publishEvent and refactors sendEvent to allow asserting unsuccessful publishes.
.changeset/empty-nip40-tests.md Adds an “empty” changeset note for the test-only change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/integration/features/nip-40/nip-40.feature Outdated
Comment thread test/integration/features/nip-40/nip-40.feature.ts Outdated
@Priyanshubhartistm
Copy link
Copy Markdown
Collaborator Author

Hey @cameri, I resolved the merge conflicts and pushed the updated branch.
Please take another look when you have a moment.
thanku

@cameri cameri self-assigned this Apr 19, 2026
Comment thread src/handlers/subscribe-message-handler.ts Outdated
Comment thread test/integration/features/nip-40/nip-40.feature.ts Outdated
@cameri cameri merged commit dec061d into cameri:main Apr 21, 2026
13 checks passed
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.

4 participants