feat: add NIP-13 Proof of Work enforcement scenarios and implementation#513
Merged
cameri merged 4 commits intocameri:mainfrom Apr 19, 2026
Merged
feat: add NIP-13 Proof of Work enforcement scenarios and implementation#513cameri merged 4 commits intocameri:mainfrom
cameri merged 4 commits intocameri:mainfrom
Conversation
Collaborator
There was a problem hiding this comment.
Pull request overview
Adds end-to-end integration coverage for NIP-13 Proof-of-Work enforcement by introducing a dedicated Cucumber feature suite and step definitions that deterministically mine event-id and pubkey PoW and toggle relay settings per scenario.
Changes:
- Added
@nip13Cucumber scenarios asserting accept/reject behavior and exactOKrejection reasons for event-id and pubkey PoW thresholds. - Implemented deterministic PoW “mining” helpers in step definitions, plus per-scenario settings overrides with restoration in an
Afterhook. - Added a Changesets file (currently empty frontmatter).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/integration/features/nip-13/nip-13.feature.ts | New step definitions: settings overrides, deterministic PoW mining, and command/result assertions. |
| test/integration/features/nip-13/nip-13.feature | New @nip13 feature with scenarios covering disabled/enabled PoW for event-id and pubkey. |
| .changeset/old-toys-stare.md | Adds a Changesets entry (needs proper package bump + summary). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cameri
reviewed
Apr 18, 2026
cameri
approved these changes
Apr 19, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds integration coverage for NIP-13 Proof of Work enforcement by introducing a new Cucumber suite under
test/integration/features/nip-13/.Included coverage:
limits.event.eventId.minLeadingZeroBits = 0accepts events regardless of PoW.limits.event.eventId.minLeadingZeroBits > 0rejects insufficient event-id PoW with exactOKreason (pow: difficulty X<Y).limits.event.eventId.minLeadingZeroBits > 0accepts sufficient event-id PoW.limits.event.pubkey.minLeadingZeroBits > 0rejects insufficient pubkey PoW with exactOKreason (pow: pubkey difficulty X<Y).limits.event.pubkey.minLeadingZeroBits > 0accepts sufficient pubkey PoW.Implementation details:
below/at leastthreshold), avoiding flaky random behavior.@nip13Afterhook to avoid cross-scenario leakage.No production API/schema behavior was changed; this is test-only coverage.
Related Issue
Motivation and Context
The relay already enforces PoW using
limits.event.eventId.minLeadingZeroBitsandlimits.event.pubkey.minLeadingZeroBits, but there was no integration coverage proving real end-to-end behavior at websocket command level.This change closes that gap by validating:
How Has This Been Tested?
Executed in the integration docker environment to ensure DB/cache/bootstrap conditions match integration expectations:
Result:
39 scenarios (39 passed)226 steps (226 passed)Also validated local type/lint during implementation:
npm run build:checknpm run lint -- test/integration/features/nip-13Types of changes
Checklist: