Skip to content

test(registry): drive discoverAll's paging loop with a fake server #10

Description

@0dillon

Summary

discoverAll pages through the registry at PAGE_LIMIT = 50 per call. It is covered only by a
live check against a registry holding a single entry, which returns on the first page and never
exercises the loop.

This is the same untested-loop shape as the readTtl chunking issue, and the two should be picked
up together — a fake server written for one is most of the fake server needed for the other.

The paging loop is worth pinning down because a bug in it is silent: a keeper that stops after the
first page maintains the first 50 contracts and never mentions the rest.

Acceptance Criteria

  • A fake server returns several pages and a test asserts every entry is discovered exactly once.
  • A test covers a total that is an exact multiple of PAGE_LIMIT, the boundary where a naive
    loop either stops early or makes one empty request too many.
  • A test covers an empty registry.
  • A test asserts the loop terminates rather than paging forever when the registry reports a
    count that disagrees with what page returns.
  • The bigint branch of requireNumber is covered, since count can decode either way.

Tech Stack

TypeScript 5.7 on Node 22+ (CI runs 22 and 24), ESM with moduleResolution: "NodeNext" — relative
imports need the .js extension. @stellar/stellar-sdk is pinned to an exact version; verify RPC
API shape against the installed copy, not against documentation. Tests are Vitest under test/ and
run without a network. npm run format:check, npm run lint, npm run build and npm test must
all be clean.

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