Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
test(tournament,bazaar): cover the scoring rules and the reconstruct finalize path
nirholas6d2c7979cfcd
diff --git a/tests/api/bazaar-endpoints.test.js b/tests/api/bazaar-endpoints.test.jsindex aa3dfa15f..4fb398dd8 100644--- a/tests/api/bazaar-endpoints.test.js+++ b/tests/api/bazaar-endpoints.test.js@@ -209,6 +209,27 @@ describe('GET /api/bazaar/list', () => {expect(payload.total).toBe(7);});+ it('pages past `limit` with `offset` and never repeats a row', async () => {+ const first = await invoke(listHandler, '/api/bazaar/list?limit=3');+ const second = await invoke(listHandler, '/api/bazaar/list?limit=3&offset=3');+ const third = await invoke(listHandler, '/api/bazaar/list?limit=3&offset=6');+ expect(first.payload.offset).toBe(0);+ expect(second.payload.offset).toBe(3);+ expect(second.payload.total).toBe(7);+ expect(third.payload.count).toBe(1);++ const walked = [...first.payload.items, ...second.payload.items, ...third.payload.items]+ .map((i) => i.uniqueKey);+ expect(walked).toHaveLength(7);+ expect(new Set(walked).size).toBe(7);++ // Past the end is an empty page, not the first page over again.+ const past = await invoke(listHandler, '/api/bazaar/list?limit=3&offset=99');+ expect(past.status).toBe(200);+ expect(past.payload.count).toBe(0);+ expect(past.payload.total).toBe(7);+ });+it('filters by network, tag, and atomic max price', async () => {const byTag = await invoke(listHandler, '/api/bazaar/list?tag=weather');expect(byTag.payload.count).toBe(2);@@ -267,6 +288,13 @@ describe('GET /api/bazaar/search', () => {const capped = await invoke(searchHandler, '/api/bazaar/search?query=weather&limit=1');expect(capped.payload.count).toBe(1);expect(capped.payload.total).toBe(2);++ // The second ranked match is only reachable through `offset`.+ const next = await invoke(searchHandler, '/api/bazaar/search?query=weather&limit=1&offset=1');+ expect(next.payload.offset).toBe(1);+ expect(next.payload.count).toBe(1);+ expect(next.payload.total).toBe(2);+ expect(next.payload.resources[0].uniqueKey).not.toBe(capped.payload.resources[0].uniqueKey);});it('returns the whole catalog for an empty query and 400s a decimal price cap', async () => {diff --git a/tests/api/reconstruct-finalize.test.js b/tests/api/reconstruct-finalize.test.jsindex b0ccdb0ec..a56df8299 100644--- a/tests/api/reconstruct-finalize.test.js+++ b/tests/api/reconstruct-finalize.test.js@@ -155,6 +155,49 @@ describe('finalizeReconstructStage', () => {const out = await finalizeReconstructStage({ userId: 'u1', jobId: 'j1', job: baseJob, glbUrl: 'https://x/m.glb' });expect(out).toEqual({ status: 'done', resultAvatarId: 'avatar-1' });});++ it('logs the draft mint outcome instead of discarding it', async () => {+ inspectGlbMock.mockReturnValue(RIGGED);+ mintDraftAgentIdentityMock.mockResolvedValueOnce({+ status: 'ok',+ agentId: 'agent-1',+ solana: { status: 'skipped', reason: 'authority_unconfigured', network: 'devnet' },+ evm: null,+ });+ const log = vi.spyOn(console, 'log').mockImplementation(() => {});+ await finalizeReconstructStage({ userId: 'u1', jobId: 'j1', job: baseJob, glbUrl: 'https://x/m.glb' });+ const line = log.mock.calls.map((c) => c.join(' ')).find((l) => l.includes('draft agent mint'));+ expect(line).toContain('solana=skipped:authority_unconfigured');+ expect(line).toContain('evm=off');+ log.mockRestore();+ });+});++// A leg that quietly reports 'skipped' is the state a deployment with no mint+// credentials sits in, and it used to be indistinguishable in the logs from the+// mint never running at all.+describe('describeDraftMint', () => {+ it('names the reason a leg was skipped', () => {+ expect(+ describeDraftMint({ status: 'ok', agentId: 'a1', solana: { status: 'skipped', reason: 'authority_unconfigured' }, evm: null }),+ ).toBe('agent=a1 solana=skipped:authority_unconfigured evm=off');+ });++ it('carries the signature of each leg that wrote to a chain', () => {+ expect(+ describeDraftMint({+ status: 'ok',+ agentId: 'a1',+ solana: { status: 'minted', signature: 'sig-1' },+ evm: { status: 'minted', txHash: '0xabc' },+ }),+ ).toBe('agent=a1 solana=minted:sig-1 evm=minted:0xabc');+ });++ it('reports a non-ok orchestration without pretending it had legs', () => {+ expect(describeDraftMint({ status: 'no_agent' })).toBe('status=no_agent');+ expect(describeDraftMint(null)).toBe('no result');+ });});describe('pollRiggingStage', () => {diff --git a/tests/tournament-scoring.test.js b/tests/tournament-scoring.test.jsindex 5b4000f0d..9aa134f8c 100644--- a/tests/tournament-scoring.test.js+++ b/tests/tournament-scoring.test.js@@ -230,6 +230,47 @@ describe('computeStandings', () => {expect(out2.get('alice')).toBe(500_000n);});+ // Idle: entered the bracket and never opened a thing. Realized P&L of exactly 0.+ const idle = {+ entry: { agent_id: 'idle', agent_name: 'Idle', status: 'active', wallet: 'WALLETidle' },+ positions: [],+ };+ // Loser: two real in-window trades that both went against it, so it is eligible+ // for prizes but its realized P&L is negative.+ const loser = {+ entry: { agent_id: 'loser', agent_name: 'Loser', status: 'active', wallet: 'WALLETloser' },+ positions: [+ pos({ mint: 'COIN_G', pnl: -0.4, opened: '2026-03-01T07:00:00.000Z' }),+ pos({ mint: 'COIN_H', pnl: -0.2, opened: '2026-03-01T08:00:00.000Z' }),+ ],+ };++ it('ranks an agent who actually traded above an idle entrant with a clean zero', () => {+ const { standings } = computeStandings(tournament, [idle, loser], { now: Date.parse(AFTER_END) });+ const idleRow = standings.find((s) => s.agent_id === 'idle');+ const loserRow = standings.find((s) => s.agent_id === 'loser');+ // On raw realized P&L the idle entrant's 0 beats the loser's -0.6, but it+ // produced no result, so it sorts last.+ expect(loserRow.score_value).toBeLessThan(idleRow.score_value);+ expect(loserRow.rank).toBe(1);+ expect(idleRow.rank).toBe(2);+ expect(idleRow.in_window_trades).toBe(0);+ });++ it('hands the prize to the trader, not to the idle entrant sitting on zero', () => {+ const { standings } = computeStandings(tournament, [idle, loser], { now: Date.parse(AFTER_END) });+ const out = allocatePrizes(1_000_000n, [{ rank: 1, bps: 10000 }], standings);+ expect(out.get('loser')).toBe(1_000_000n);+ expect(out.get('idle')).toBeUndefined();+ });++ it('keeps idle entrants below traders without disturbing the traders’ own order', () => {+ const { standings } = computeStandings(tournament, [carol, bob, idle, alice], { now: Date.parse(AFTER_END) });+ // Bob (+5) then Alice (+3) as before; Carol and Idle both closed nothing.+ expect(standings.map((s) => s.agent_id).slice(0, 2)).toEqual(['bob', 'alice']);+ expect(standings.slice(2).map((s) => s.in_window_trades)).toEqual([0, 0]);+ });+it('a practice bracket counts paper trades and ranks everyone, prizes nobody', () => {const practice = { ...tournament, bracket: 'practice' };const { standings } = computeStandings(practice, [carol], { now: Date.parse(AFTER_END) });