Skip to content

test(transport): cover accepted server identity formats #84

Description

@1amKhush

Problem

parseServerIdentity accepts three externally supplied identity formats—hex pubkeys, npub, and nprofile—but currently has no focused unit tests. A regression here can prevent the client transport from starting or silently discard relay hints.

Scope

Add src/transport/nostr-client/server-identity.test.ts covering:

  • a valid 64-character hex pubkey;
  • uppercase or mixed-case hex if supported by the existing contract;
  • a valid npub identity;
  • a valid nprofile identity with relay hints;
  • an nprofile without relay hints;
  • malformed, unsupported, and empty input;
  • the stable transport-facing error message for invalid input.

Use nostr-tools encoders to build valid Bech32 fixtures rather than hard-coding opaque values where practical.

Non-goals

  • Do not add new identity formats.
  • Do not change relay discovery or connection behavior.
  • Keep production changes out of scope unless a test exposes a confirmed defect.

Acceptance criteria

  • Tests exercise all three documented input formats and the common error path.
  • Tests are deterministic and make no relay or network calls.
  • Existing tests, lint, and type checking continue to pass.

Verification

bun test src/transport/nostr-client/server-identity.test.ts
bun lint
bun typecheck

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions