Intelligence, Advanced Charting & Trading Platform

1 import test from 'node:test';
2 import assert from 'node:assert/strict';
3 import { buildDataProofArtifact } from '../src/data-proof-artifact.mjs';
4
5 test('builds immutable evidence artifact from three required Phase 1 reports', () => {
6 const artifact = buildDataProofArtifact({
7 generatedAt: new Date('2026-10-05T12:10:00Z'),
8 reports: [
9 { providerCode: 'navasan', canonicalSymbol: 'USD_IRT_FREE', status: 'PASS', checkedAt: '2026-10-05T12:09:00Z' },
10 { providerCode: 'navasan', canonicalSymbol: 'GOLD18_IRT', status: 'PASS', checkedAt: '2026-10-05T12:09:00Z' },
11 { providerCode: 'alpha_vantage', canonicalSymbol: 'XAU_USD', status: 'PASS', checkedAt: '2026-10-05T12:09:00Z' },
12 ],
13 });
14 assert.equal(artifact.phase, 1);
15 assert.equal(artifact.status, 'PASS');
16 assert.deepEqual(artifact.requiredSymbols, ['GOLD18_IRT','USD_IRT_FREE','XAU_USD']);
17 });
18
19 test('fails aggregate proof when any required report fails', () => {
20 const artifact = buildDataProofArtifact({
21 generatedAt: new Date('2026-10-05T12:10:00Z'),
22 reports: [
23 { providerCode: 'navasan', canonicalSymbol: 'USD_IRT_FREE', status: 'PASS', checkedAt: '2026-10-05T12:09:00Z' },
24 { providerCode: 'navasan', canonicalSymbol: 'GOLD18_IRT', status: 'FAIL', checkedAt: '2026-10-05T12:09:00Z' },
25 { providerCode: 'alpha_vantage', canonicalSymbol: 'XAU_USD', status: 'PASS', checkedAt: '2026-10-05T12:09:00Z' },
26 ],
27 });
28 assert.equal(artifact.status, 'FAIL');
29 });
30
31 test('refuses to certify Phase 1 when a required symbol is missing or duplicated', () => {
32 const base = [
33 { providerCode: 'navasan', canonicalSymbol: 'USD_IRT_FREE', status: 'PASS', checkedAt: '2026-10-05T12:09:00Z' },
34 { providerCode: 'navasan', canonicalSymbol: 'GOLD18_IRT', status: 'PASS', checkedAt: '2026-10-05T12:09:00Z' },
35 ];
36 assert.throws(() => buildDataProofArtifact({ generatedAt: new Date('2026-10-05T12:10:00Z'), reports: base }), /required/i);
37 assert.throws(() => buildDataProofArtifact({ generatedAt: new Date('2026-10-05T12:10:00Z'), reports: [...base, base[0]] }), /duplicate/i);
38 });