Skip to content

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.

test(irl): stub the on-chain settlement proof so the pay specs test what they claim

nirholas05ebfa918a42
diff --git a/tests/api/irl-interactions-privacy.test.js b/tests/api/irl-interactions-privacy.test.js
index 14d654ba6..dcd782923 100644
--- a/tests/api/irl-interactions-privacy.test.js
+++ b/tests/api/irl-interactions-privacy.test.js
@@ -51,6 +51,12 @@ vi.mock('../../api/_lib/rate-limit.js', () => ({
}));
vi.mock('../../api/_lib/notify.js', () => ({ insertNotification: vi.fn() }));
vi.mock('../../api/_lib/alerts.js', () => ({ sendOpsAlert: vi.fn() }));
+// This spec is about what a pay stores, not about proving it: stub the on-chain
+// check to a match so an unstubbed RPC read cannot turn every accepted pay into
+// a 202 pending and hide the assertions behind it.
+vi.mock('../../api/_lib/settlement-verify.js', () => ({
+ verifySettlement: vi.fn(async () => ({ status: 'match' })),
+}));
const { default: handler } = await import('../../api/irl/interactions.js');
diff --git a/tests/api/irl-interactions.test.js b/tests/api/irl-interactions.test.js
index 0fbcf513b..b702fbe1d 100644
--- a/tests/api/irl-interactions.test.js
+++ b/tests/api/irl-interactions.test.js
@@ -67,6 +67,15 @@ vi.mock('../../api/_lib/alerts.js', () => ({
sendOpsAlert: (...a) => alertMock(...a),
}));
+// A pay only counts once the handler has seen the settlement on-chain, so the
+// proof is the thing under test here, not the RPC that fetches it. Left
+// unstubbed these specs hit a real network read, come back `pending`, and every
+// assertion about a *verified* pay silently tests the pending path instead.
+let settlementProof = { status: 'match' };
+vi.mock('../../api/_lib/settlement-verify.js', () => ({
+ verifySettlement: vi.fn(async () => settlementProof),
+}));
+
const { default: handler } = await import('../../api/irl/interactions.js');
// A real Solana settlement signature (base58, 43–88 chars) and the $THREE mint —
@@ -187,6 +196,20 @@ describe('POST — pay is only recorded with a verified settlement', () => {
expect(alertMock).toHaveBeenCalled();
});
+ it('holds a pay at 202 while the settlement is not yet visible on-chain', async () => {
+ settlementProof = { status: 'pending' };
+ const { res, body } = await post({
+ pinId: 'pin-1', type: 'pay', amount: 50000, currencyMint: THREE_MINT, signature: SOL_SIG,
+ });
+ expect(res.statusCode).toBe(202);
+ expect(body.pending).toBe(true);
+ // The row is kept so the sweep can prove it later, but nothing downstream
+ // treats it as money yet.
+ expect(lastInsert).not.toBeNull();
+ expect(notifyMock).not.toHaveBeenCalled();
+ expect(alertMock).not.toHaveBeenCalled();
+ });
+
it('de-dupes a pay by signature (one settlement → one row)', async () => {
paySigDupeRow = { id: 'ix-paid' };
const { res, body } = await post({