test: optimize NIP-44 unit tests#624
Conversation
🦋 Changeset detectedLatest commit: a3b2d73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
There was a problem hiding this comment.
Pull request overview
This PR optimizes the NIP-44 unit test suite by reusing precomputed secp256k1-derived keys across tests, reducing repeated expensive cryptographic operations and improving overall unit test runtime (per issue #611).
Changes:
- Precompute and reuse sender/recipient pubkeys and conversation keys at module scope for the NIP-44 unit tests.
- Remove per-test secp256k1 pubkey derivation and conversation-key derivation calls in favor of shared constants.
- Add a changeset entry for the PR.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/unit/utils/nip44.spec.ts | Reuses precomputed keys to avoid repeated secp256k1 operations across the test suite. |
| .changeset/vast-signs-melt.md | Adds a changeset file associated with the change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const PUB1 = pubkeyFromPrivkey(SEC1) | ||
| const PUB2 = pubkeyFromPrivkey(SEC2) | ||
| const PUB3 = pubkeyFromPrivkey(SEC3) | ||
| const CONVERSATION_KEY = getConversationKey(SEC1, PUB2) | ||
| const RECIPIENT_CONVERSATION_KEY = getConversationKey(SEC2, PUB1) | ||
| const DIFFERENT_CONVERSATION_KEY = getConversationKey(SEC1, PUB3) |
There was a problem hiding this comment.
Can we move all these to a beforeAll? Otherwise this runs outside the test
There was a problem hiding this comment.
Done, moved derived pubkeys and conversation keys into a Mocha before hook. now they will run inside test lifecycle.
Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
Fixes:- #611