Skip to content

Conversation

@tcheeric
Copy link
Owner

@tcheeric tcheeric commented Oct 9, 2025

Summary

Strengthen client/handler subscription and request paths with deeper tests, raise coverage in crypto and event utilities, add ops documentation, and minor NIP‑57 enhancements. Bump version
to 0.6.5‑SNAPSHOT and consolidate test structure.

Related issue: #____

What changed?

  • Tests (API/client)
    • WebSocket handler: close sequencing, idempotent close, CLOSE frame emission, request error wrapping, sub‑id correctness, dispatcher ensure/de‑duplication, subscription manager close
      aggregation.
    • NostrSpringWebSocketClient: logging WARNs on errors (subscribe/close), relay snapshot, integration delegation to handler.
    • SpringWebSocketClient (client module): retry tests for send and subscribe (message and raw JSON), timeout behavior.
  • Tests (NIPs)
    • NIP‑01 message encoding tests (EVENT/REQ/CLOSE/EOSE/NOTICE).
    • NIP‑42 canonical auth event + AUTH messages.
    • NIP‑46 request/response compliance, multi‑param round‑trip via NIP‑44.
    • NIP‑65 relay list (marker, order, map variant).
    • NIP‑99 classified listings (required/optional tags, price integrity).
  • Tests (crypto/event utilities)
    • Bech32: npub/nsec/note, BECH32M, malformed inputs, known vector.
    • Schnorr: sign/verify round‑trip, negative cases, invalid lengths.
    • EventJsonMapper: singleton + constructor guard.
    • EventTypeChecker: ranges + naming + constructor guard.
    • EventSerializer: determinism, tags array presence.
    • GenericEvent support: serializer/updater/validator happy/error paths.
  • NIP‑57 enhancements
    • Add description_hash tag to zap receipts.
    • Basic invoice msat parsing (HRP) and requested‑vs‑invoice amount check (best effort).
  • Client diagnostics
    • DefaultNoteService now records per‑relay failure details (timestamp, relay name/URI, cause + root cause) and optional failure listener.
    • NostrSpringWebSocketClient exposes getLastSendFailures/getLastSendFailureDetails and onSendFailures.
  • Docs
    • New operations docs (logging, metrics, configuration) and diagnostics how‑to with MDC snippet.
    • Tests overview in docs/README.md and test READMEs for API client/handler and client module; CONTRIBUTING pointers.
  • CI
    • Matrix for docker and no‑docker modes (added earlier in this branch’s work).
  • Version bump
    • 0.6.4 → 0.6.5‑SNAPSHOT across poms; new branch: chore/tests-coverage-enhancements.

BREAKING

None.

Review focus

  • Handler close sequencing and error aggregation logic acceptable?
  • NIP‑57 description_hash and HRP amount check behavior OK (best‑effort validation)?
  • Logging via slf4j‑test: message templates and argument content.
  • Failure diagnostics API surface (DefaultNoteService + NostrSpringWebSocketClient).
  • Test organization (nostr.api.client and client module) and readability.

Checklist

  • Scope ≤ 300 lines (or split/stack)
  • Title is verb + object (e.g., “Refactor auth middleware to async”)
  • Description links the issue and answers “why now?”
  • BREAKING flagged if needed
  • Tests/docs updated (if relevant)

Verification

  • Command: mvn -q -Pno-docker verify
  • Note: In restricted CI/sandbox environments, Docker/Testcontainers ITs are skipped by -Pno-docker. The API/client tests and updated unit tests run without network/Docker. In full CI
    (docker matrix), integration ITs execute.

Why now?

  • Raises coverage in critical paths (client/handler, crypto, event support) identified as low in the coverage analysis.
  • Improves operational readiness (logging/metrics/config docs + diagnostics) and developer velocity (organized tests, READMEs, CONTRIBUTING pointers).
  • Enhances NIP‑57 compliance with description_hash and invoice amount checks.

@codecov-commenter
Copy link

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@tcheeric tcheeric merged commit d5a3c60 into develop Oct 9, 2025
3 checks passed
@tcheeric tcheeric deleted the chore/tests-coverage-enhancements branch October 9, 2025 00:22
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines 44 to +48
String description = EventJsonMapper.mapper().writeValueAsString(zapRequestEvent);
// Store description (escaped) and include description_hash for validation
receipt.addTag(NIP57TagFactory.description(StringEscapeUtils.escapeJson(description)));
var hash = nostr.util.NostrUtil.bytesToHex(nostr.util.NostrUtil.sha256(description.getBytes()));
receipt.addTag(NIP57TagFactory.descriptionHash(hash));

Choose a reason for hiding this comment

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

P1 Badge Use explicit UTF-8 when hashing zap description

The new zap receipt builder computes the description_hash using description.getBytes() before hashing. String.getBytes() relies on the platform default charset, so the hash will differ on systems whose default charset is not UTF‑8 (e.g. Windows). NIP‑57 specifies the hash over the UTF‑8 encoded JSON; using the default charset will cause receipts built on such platforms to fail validation elsewhere. Encode with getBytes(StandardCharsets.UTF_8) to ensure deterministic hashes.

Useful? React with 👍 / 👎.

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.

3 participants