@davoodmehraban89 / VELYQOR / commits / 0fadaf7
Fork 0

Intelligence, Advanced Charting & Trading Platform

test: fix live proof runner cwd independence (#26)

davoodmehraban89 committed Oct 14, 2026 at 22:35 UTC 0fadaf7dc7df96dbd7aadf0bf9eaf7bbc83ce257
1 file changed +29 -2
packages/market-domain/test/live-data-proof-runner.test.mjs
+29 -2
@@ -1,2 +1,29 @@
1 -import test from 'node:test';import assert from 'node:assert/strict';import {spawnSync} from 'node:child_process';
2 -test('live proof runner fails closed when provider credentials are absent',()=>{const env={...process.env};delete env.NAVASAN_API_KEY;delete env.ALPHAVANTAGE_API_KEY;const run=spawnSync(process.execPath,['scripts/phase1-live-data-proof.mjs'],{cwd:process.cwd(),env,encoding:'utf8'});assert.notEqual(run.status,0);assert.match(run.stderr+run.stdout,/NAVASAN_API_KEY is required/)});
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { spawnSync } from 'node:child_process';
4 +import { tmpdir } from 'node:os';
5 +import { fileURLToPath } from 'node:url';
6 +
7 +// Resolve from this source file, not process.cwd(). This test must also work
8 +// under CI, a Windows Desktop Commander shell, and an unrelated launch folder.
9 +const runnerPath = fileURLToPath(new URL('../../../scripts/phase1-live-data-proof.mjs', import.meta.url));
10 +
11 +test('live proof runner fails closed without provider credentials, independent of cwd', () => {
12 + const env = { ...process.env };
13 + delete env.NAVASAN_API_KEY;
14 + delete env.ALPHAVANTAGE_API_KEY;
15 +
16 + const run = spawnSync(process.execPath, [runnerPath], {
17 + cwd: tmpdir(),
18 + env,
19 + encoding: 'utf8',
20 + timeout: 15_000,
21 + });
22 +
23 + assert.equal(run.error, undefined, 'child process must start');
24 + assert.notEqual(run.status, 0, 'live data proof must fail closed');
25 + assert.match(
26 + `${run.stderr ?? ''}\n${run.stdout ?? ''}`,
27 + /NAVASAN_API_KEY is required/,
28 + );
29 +});