test: add missing unit tests for message factory functions#470
Open
d1vyanshu-kumar wants to merge 1 commit intocameri:mainfrom
Open
test: add missing unit tests for message factory functions#470d1vyanshu-kumar wants to merge 1 commit intocameri:mainfrom
d1vyanshu-kumar wants to merge 1 commit intocameri:mainfrom
Conversation
…ionMessage and createRelayedEventMessage These three message factory functions in src/utils/messages.ts were exported and used across the relay but had no tests in the spec file. - createCommandResult (NIP-20): covers success=true with empty reason and success=false with a rejection reason string - createSubscriptionMessage (NIP-01 REQ): covers single-filter and multi-filter cases, verifying the spread into index positions 2+ - createRelayedEventMessage: covers both code paths — the branch that returns a 2-element tuple when no secret is passed, and the branch that appends the secret as a third element
Author
|
@cameri Could you please review this PR and let me know if it looks good? |
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.
Summary
This PR adds missing unit coverage for message factory functions in
src/utils/messages.ts.What changed
Added tests in
test/unit/utils/messages.spec.tsfor:createCommandResultCovers both success and rejection cases.
createSubscriptionMessageCovers single-filter and multi-filter cases.
createRelayedEventMessageCovers both paths: with and without a secret.
Why
These functions are exported and used by the relay, but they previously had missing test coverage. Adding these tests helps catch regressions in message creation logic before they reach production.
Verification
npm run test:unit