Skip to content

Optimize unit tests: nip05.spec.ts & nip03.spec.ts (network) #610

Closed

Description

@chappie-daemon

Both nip05.spec.ts (42 tests) and nip03.spec.ts (34 tests) perform HTTP/network operations:

  • Network calls even when mocked
  • Promise/async overhead
  • Timeout handling

These 76 combined tests are slow due to network I/O. Goal: Reduce execution time by at least 25% through improved mocking and test consolidation.

Activity

  1. Ferryx349 commented on May 23, 2026

    @Ferryx349
    Collaborator

    @Anshumancanrock have u started working around it, or still up to grab?

  2. Anshumancanrock commented on May 28, 2026

    @Anshumancanrock
    Contributor

    Hii @cameri , I dug into this and found that nip03.spec.ts is completely synchronous. It is just a binary parser with no network activity at all. The async tests in nip05.spec.ts rely on stub.resolves, which fires as a microtask rather than real IO. All 76 tests finish in roughly 40 ms locally.

    I did clean up the structural stuff though. I hoisted the stub lifecycle into the before and after hooks, pulled the SSRF guard out so it only runs once instead of repeating it for every test, and created the shared buffers ahead of time at module scope. Happy to open a PR if this helps.

  3. cameri commented on May 28, 2026

    @cameri
    Owner

    @Anshumancanrock Okay not sure why it was taking longer on my machine when I inspected these tests. I'd appreciate if you open a PR with your structural changes.

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

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions