Skip to content

Conversation

tcheeric
Copy link
Owner

Summary

  • add unit tests under impl to exercise validate() on ContactListEvent, ZapRequestEvent, and TextNoteEvent
  • cover positive cases and missing tag, wrong kind, and invalid content scenarios

Testing

  • mvn -q verify
  • Results show all new tests pass:
    • ContactListEventValidateTest: Tests run: 4, Failures: 0
    • ZapRequestEventValidateTest: Tests run: 6, Failures: 0
    • TextNoteEventValidateTest: Tests run: 4, Failures: 0

https://chatgpt.com/codex/tasks/task_b_688a850853888331a9229ebce247afe0

Copy link
Contributor

@Copilot 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 adds comprehensive unit tests for the validate() method across three key event types: ContactListEvent, ZapRequestEvent, and TextNoteEvent. The tests systematically cover both positive validation scenarios and various failure cases including missing required tags, wrong event kinds, and invalid content.

  • Adds validation test coverage for three event types with both success and failure scenarios
  • Tests specific validation requirements for each event type (e.g., required tags, content validation)
  • Implements systematic test patterns across all event validation test classes

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ContactListEventValidateTest.java Tests validation for contact list events including P-tag requirements and content validation
ZapRequestEventValidateTest.java Tests validation for zap request events including amount, lnurl, and P-tag requirements
TextNoteEventValidateTest.java Tests validation for text note events with tag and content requirements using reflection


private void clearTags(TextNoteEvent event) {
try {
Field f = GenericEvent.class.getDeclaredField("tags");
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

Using reflection to access private fields makes tests brittle and tightly coupled to implementation details. Consider providing a package-private setter method or using a test-specific constructor instead.

Copilot uses AI. Check for mistakes.

List<BaseTag> tags = new ArrayList<>();
tags.add(new PubKeyTag(new PublicKey(HEX_64_B)));
GenericTag amountTag = new GenericTag("amount");
amountTag.addAttribute(new ElementAttribute("amount", "1000"));
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The attribute key "amount" is duplicated with the tag code. This could be confusing and error-prone. Consider using a different attribute key or adding a comment explaining why both use the same value.

Suggested change
amountTag.addAttribute(new ElementAttribute("amount", "1000"));
amountTag.addAttribute(new ElementAttribute("amountValue", "1000"));

Copilot uses AI. Check for mistakes.

amountTag.addAttribute(new ElementAttribute("amount", "1000"));
tags.add(amountTag);
GenericTag lnurlTag = new GenericTag("lnurl");
lnurlTag.addAttribute(new ElementAttribute("lnurl", "lnurl-value"));
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The attribute key "lnurl" is duplicated with the tag code. This could be confusing and error-prone. Consider using a different attribute key or adding a comment explaining why both use the same value.

Suggested change
lnurlTag.addAttribute(new ElementAttribute("lnurl", "lnurl-value"));
lnurlTag.addAttribute(new ElementAttribute("lnurl_value", "lnurl-value"));

Copilot uses AI. Check for mistakes.

@tcheeric tcheeric merged commit c4b5580 into develop Jul 30, 2025
@tcheeric tcheeric deleted the codex/add-tests-for-validate-in-events branch July 30, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant