Package Apple Silicon VM exports and cached runtime switching with local cabinet controls and conagent provisioning. Preserve experimental SPIKE 2 emulation. Improve preparation concurrency, Ghidra checkpoints, signature importing, sound indexing and client-side spectrograms. Include regression tests and validation notes.
57 lines
3.0 KiB
JavaScript
57 lines
3.0 KiB
JavaScript
// Run after: npm --prefix workbench/stern-catalog run build
|
|
import assert from 'node:assert/strict';
|
|
import { createRequire } from 'node:module';
|
|
import { createServer } from 'node:http';
|
|
import { once } from 'node:events';
|
|
|
|
const require = createRequire(new URL('../workbench/stern-catalog/package.json', import.meta.url));
|
|
require('reflect-metadata');
|
|
const express = require('@theia/core/shared/express');
|
|
const { ArchiveProxy } = require('./lib/node/backend-module');
|
|
const received = [];
|
|
const upstream = createServer(async (req, res) => {
|
|
const chunks = [];
|
|
for await (const chunk of req) { chunks.push(chunk); }
|
|
received.push({ url: req.url, body: Buffer.concat(chunks), headers: req.headers });
|
|
res.end('ok');
|
|
});
|
|
upstream.listen(0, '127.0.0.1');
|
|
await once(upstream, 'listening');
|
|
process.env.VERSTACK_API_PORT = String(upstream.address().port);
|
|
process.env.VERSTACK_EMULATOR_PORT = String(upstream.address().port);
|
|
const app = express();
|
|
app.use(express.json());
|
|
app.use('/api/buffer', express.raw({ type: 'application/octet-stream' }));
|
|
new ArchiveProxy().configure(app);
|
|
const proxy = app.listen(0, '127.0.0.1');
|
|
await once(proxy, 'listening');
|
|
const base = `http://127.0.0.1:${proxy.address().port}`;
|
|
try {
|
|
const sig = Buffer.concat([Buffer.from('IDASGN'), Buffer.from([9, 0, 255, 128, 0, 13, 10])]);
|
|
const pat = Buffer.from(`${'55'.repeat(32)} 00 0000 0020 :0000 known\n---\n`);
|
|
for (const [name, bytes] of [['tmnt.sig', sig], ['tmnt.pat', pat]]) {
|
|
const url = `/api/signatures/libraries?name=${name}&language=ARM%3ALE%3A32%3Av7`;
|
|
const response = await fetch(base + url, {
|
|
method: 'POST', headers: { 'Content-Type': 'application/octet-stream', 'X-Verstack-Client': '1' }, body: bytes
|
|
});
|
|
assert.equal(response.status, 200);
|
|
const request = received.at(-1);
|
|
assert.equal(request.url, url);
|
|
assert.deepEqual(request.body, bytes);
|
|
assert.equal(request.headers['x-verstack-client'], '1');
|
|
}
|
|
await fetch(base + '/api/buffer', { method: 'POST', headers: { 'Content-Type': 'application/octet-stream' }, body: sig });
|
|
assert.deepEqual(received.at(-1).body, sig, 'Already parsed buffers remain binary');
|
|
for (const [path, method, type] of [['/api/imports', 'POST', 'application/json'], ['/api/settings', 'PUT', 'application/json'], ['/emulator/start', 'POST', 'application/json']]) {
|
|
const value = { title: 'Teenage Mutant Ninja Turtles', options: { analyze: true } };
|
|
await fetch(base + path, { method, headers: { 'Content-Type': type }, body: JSON.stringify(value, null, 2) });
|
|
assert.deepEqual(JSON.parse(received.at(-1).body), value, 'Consumed JSON bodies are forwarded');
|
|
}
|
|
await fetch(base + '/api/info');
|
|
assert.equal(received.at(-1).body.length, 0);
|
|
console.log('PASS: SIG/PAT bytes, parsed buffers, JSON mutations, and GET forwarding');
|
|
} finally {
|
|
proxy.closeAllConnections(); upstream.closeAllConnections();
|
|
await Promise.all([new Promise(resolve => proxy.close(resolve)), new Promise(resolve => upstream.close(resolve))]);
|
|
}
|