agentcomply / tree / test/live.test.js ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
// Live, read-only, free preview routes only ($0). Run: npm run test:live
import test from 'node:test';
import assert from 'node:assert/strict';
import { screen } from '../src/core.js';
import { MemoryStore } from '../src/store.js';
import { testSigner, policy } from './helpers.js';
const live = process.env.LIVE === '1';
const d = async () => ({ fetch, signer: await testSigner(), store: new MemoryStore(), policy, timeoutMs: 30000 });

test('live: Lazarus Group (OFAC SDN) -> block', { skip: !live }, async () => {
  const r = await screen({ payTo: '0x098B716B8Aaf21512996dC57EB0615e2383E2f96', chain: 'ethereum' }, await d());
  assert.equal(r.body.verdict, 'block');
});
test('live: vitalik.eth -> ok or caution (never block), resolved', { skip: !live }, async () => {
  const r = await screen({ payTo: 'vitalik.eth', chain: 'ethereum', amount_usd: 5 }, await d());
  assert.ok(['ok', 'caution'].includes(r.body.verdict));
  assert.equal(r.body.receipt.subject.resolved_address, '0xd8da6bf26964af9d7eed9e03e53415d37aa96045');
});
test('live: unknown ENS -> 400', { skip: !live }, async () => {
  const r = await screen({ payTo: 'nonexistent-zzzq9.eth', chain: 'ethereum' }, await d());
  assert.equal(r.status, 400);
});
test('live: USDC contract as payTo with intent=pay -> not ok', { skip: !live }, async () => {
  const r = await screen({ payTo: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', chain: 'base' }, await d());
  assert.notEqual(r.body.verdict, 'ok');
});

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