Skip to content

test: optimize NIP-44 unit tests#624

Open
Ferryx349 wants to merge 2 commits into
cameri:mainfrom
Ferryx349:m1
Open

test: optimize NIP-44 unit tests#624
Ferryx349 wants to merge 2 commits into
cameri:mainfrom
Ferryx349:m1

Conversation

@Ferryx349
Copy link
Copy Markdown
Collaborator

Fixes:- #611

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 23, 2026

🦋 Changeset detected

Latest commit: a3b2d73

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When 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

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 23, 2026

Coverage Status

coverage: 65.108%. remained the same — Ferryx349:m1 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

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.

Comment thread test/unit/utils/nip44.spec.ts Outdated
Comment on lines +28 to +33
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)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can we move all these to a beforeAll? Otherwise this runs outside the test

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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>
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