xdrcheck replay can judge what your
indexer stores.
main.go is the smallest useful replay adapter. It lets xdrcheck replay drive an indexer over the corpus through
the protocol xcc.adapter/1 (docs/adapter-protocol.md), and reports two
observation kinds:
- receipts: how many transactions and operations the indexer holds per ledger;
- transactions: each transaction’s hash, apply-order index, success and fee charged.
../baseline.
The adapter imports only go-stellar-sdk and the public package
go/adapterkit (github.com/OWNER/REPO/go/adapterkit): the
protocol types, the stdio transport (adapterkit.Main), error codes, and kittest for your own go test.
Nothing under internal/ is needed; a test copies main.go and protocol_test.go into a module of their own
and builds, vets and tests them there.
Try it
From the repository’sgo/ directory:
make demo (scripts/demo.sh) runs the same template
with one planted bug and shows what the report says about it.
Copy it
-
Copy
main.goandprotocol_test.gointo your own module and require the kit: -
Work through the places marked
REPLACE:- Describe: your adapter’s name, the inputs your indexer reads (
sep54-dir,sep54-s3,rpc), and its envelope:indexer_gateif it refuses ledgers on purpose,sdk_limitfor the protocols its SDK decodes, ornone. Declare only the kinds you map. - Prepare: create a fresh, empty store under
p.Workdir; refuse one that already holds data. - Ingest: start your indexer on
p.Inputandp.Range(adapterkit.RunChildruns a separate program with a deadline), read its own progress marker and exit record, never its log text, and report the status the facts justify (adapter-protocol.md §4.3). - Observe: one query per kind, one fact per stored record, values exactly as stored. A ledger you hold nothing for is left out: that is how a drop is seen.
- Teardown: drop the store.
- Describe: your adapter’s name, the inputs your indexer reads (
-
Check it:
go test ./...(in-process protocol checks), thenxdrcheck replay --adapter ./my-adapter --selftest, then a replay with--report DIR.DIR/REPORT.mdlists each failure with what the ledger holds, what your indexer held, and the command that replays that entry alone. -
Add kinds as you go: participants, state changes, movements, addresses. Each switches on that kind’s
expectations for every entry;
../baselineshows how each is derived.
examples/adapter-ts for the TypeScript twin of this template.
When it fails
What each class means: replay-harness.md §7. Every message and status rule:
adapter-protocol.md.
Limits
- The harness judges only the kinds you declare in
describe. An indexer that stores participants wrongly passes until you add theparticipantskind. xdrcheck replayruns on Linux only.