feat: add NIP-13 Proof of Work enforcement scenarios and implementation - #513
Conversation
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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: