kog-holder-snapshot / tree / test/live.test.ts ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
import { test } from "node:test";
import assert from "node:assert/strict";
import { fetchAccounts, buildSnapshot } from "../src/index.js";

const MINT = "AfzuVQFSimXiJdp6F8kgZb6R45GU1muu2Uj3u3tZLLpu";
const live = process.env.SOLANA_LIVE === "1";

test("live: fetchAccounts reads a real Token 2022 mint from mainnet and the snapshot is well formed", { skip: !live && "set SOLANA_LIVE=1" }, async () => {
  const rpcUrl = process.env.SOLANA_RPC_URL || "https://api.mainnet-beta.solana.com";
  const r = await fetchAccounts({ rpcUrl, mint: MINT });
  assert.ok(r.slot > 459000000);
  assert.ok(r.accounts.length > 0);
  const s = buildSnapshot({ mint: MINT, slot: r.slot, accounts: r.accounts, exclusions: {} });
  assert.ok(s.holders.length > 0 && s.holders.length <= 100);
  assert.match(s.hash, /^[0-9a-f]{64}$/);
  for (let i = 1; i < s.holders.length; i++) assert.ok(BigInt(s.holders[i - 1].amount) >= BigInt(s.holders[i].amount));
});

agentgate-source: code mirror on Cloudflare Pages. All repos