mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -1,101 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import appVoiceSessionFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/app_voice_session.json';
|
||||
import {coalesceVoiceEngineV2OutboundStats} from '@fluxer/voice_engine_v2/src/policies/voiceStats';
|
||||
import type {VoiceEngineV2OutboundStats} from '@fluxer/voice_engine_v2/src/protocol/types';
|
||||
import {
|
||||
createVoiceEngineV2DeterministicPlatformPort,
|
||||
createVoiceEngineV2SeededRandomPort,
|
||||
createVoiceEngineV2SystemClockPort,
|
||||
} from '@fluxer/voice_engine_v2/src/runtime';
|
||||
import {
|
||||
replayVoiceEngineV2EventLogFixture,
|
||||
type VoiceEngineV2EventLogFixture,
|
||||
} from '@fluxer/voice_engine_v2/src/testing/eventLogReplay';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
const fixture = appVoiceSessionFixtureJson as unknown as VoiceEngineV2EventLogFixture;
|
||||
|
||||
describe('voice engine v2 determinism guarantees', () => {
|
||||
it('produces byte-identical snapshot output across fresh replay runs', () => {
|
||||
const first = replayVoiceEngineV2EventLogFixture(fixture);
|
||||
const second = replayVoiceEngineV2EventLogFixture(fixture);
|
||||
|
||||
const firstBytes = JSON.stringify(first.finalSnapshot);
|
||||
const secondBytes = JSON.stringify(second.finalSnapshot);
|
||||
|
||||
expect(secondBytes).toBe(firstBytes);
|
||||
expect(second.finalSnapshot).toEqual(first.finalSnapshot);
|
||||
expect(second.commandBatches).toEqual(first.commandBatches);
|
||||
});
|
||||
|
||||
it('keeps Map-style grouping iteration order stable across runs', () => {
|
||||
const tracks: Array<VoiceEngineV2OutboundStats> = buildGroupedOutboundTracks();
|
||||
|
||||
const firstRun = coalesceVoiceEngineV2OutboundStats(tracks);
|
||||
const secondRun = coalesceVoiceEngineV2OutboundStats(tracks);
|
||||
const firstKeys = firstRun.map((track) => `${track.kind}:${track.trackSid}`);
|
||||
const secondKeys = secondRun.map((track) => `${track.kind}:${track.trackSid}`);
|
||||
|
||||
expect(secondKeys).toEqual(firstKeys);
|
||||
expect(firstKeys.length).toBe(2);
|
||||
expect(firstKeys[0]).toBe('audio:micA');
|
||||
expect(firstKeys[1]).toBe('video:camA');
|
||||
});
|
||||
|
||||
it('produces stable seeded random sequences for replay-friendly entropy', () => {
|
||||
const firstSequence = drawSeededValues(7, 8);
|
||||
const secondSequence = drawSeededValues(7, 8);
|
||||
|
||||
expect(secondSequence).toEqual(firstSequence);
|
||||
expect(new Set(firstSequence).size).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it('isolates the system clock port against retrograde wall clock motion', () => {
|
||||
let readingIndex = 0;
|
||||
const readings = [500, 200, 800, Number.NaN, -10];
|
||||
const clock = createVoiceEngineV2SystemClockPort({
|
||||
read(): number {
|
||||
const value = readings[readingIndex] ?? 0;
|
||||
readingIndex += 1;
|
||||
return value;
|
||||
},
|
||||
});
|
||||
|
||||
const observed = [clock.now(), clock.now(), clock.now(), clock.now(), clock.now()];
|
||||
const monotonic = observed.every((value, index) => index === 0 || value >= (observed[index - 1] ?? 0));
|
||||
|
||||
expect(monotonic).toBe(true);
|
||||
expect(observed[0]).toBe(500);
|
||||
});
|
||||
|
||||
it('exposes injectable Clock and Random ports through the runtime options surface', () => {
|
||||
const platform = createVoiceEngineV2DeterministicPlatformPort(42);
|
||||
|
||||
const first = platform.clock.now();
|
||||
const second = platform.clock.now();
|
||||
const randomValue = platform.random.next();
|
||||
|
||||
expect(second).toBeGreaterThan(first);
|
||||
expect(randomValue).toBeGreaterThanOrEqual(0);
|
||||
expect(randomValue).toBeLessThan(1);
|
||||
});
|
||||
});
|
||||
|
||||
function buildGroupedOutboundTracks(): Array<VoiceEngineV2OutboundStats> {
|
||||
return [
|
||||
{trackSid: 'micA', source: 'microphone', kind: 'audio', codec: 'opus', bitrateKbps: 32, packetsLost: 0},
|
||||
{trackSid: 'micA', source: 'microphone', kind: 'audio', codec: 'opus', bitrateKbps: 30, packetsLost: 1},
|
||||
{trackSid: 'camA', source: 'camera', kind: 'video', codec: 'h264', bitrateKbps: 1500, packetsLost: 2, fps: 30},
|
||||
{trackSid: 'camA', source: 'camera', kind: 'video', codec: 'h264', bitrateKbps: 1600, packetsLost: 3, fps: 31},
|
||||
];
|
||||
}
|
||||
|
||||
function drawSeededValues(seed: number, count: number): Array<number> {
|
||||
const random = createVoiceEngineV2SeededRandomPort(seed);
|
||||
const values: Array<number> = [];
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
values.push(random.next());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
/// <reference types="node" />
|
||||
|
||||
import {readFileSync} from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import * as implementationsBarrel from '@fluxer/voice_engine_v2/src/implementations';
|
||||
import * as packageBarrel from '@fluxer/voice_engine_v2/src/index';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
||||
const PUBLIC_EXPORT_FILES = ['index.ts', 'implementations/index.ts'];
|
||||
const QUARANTINED_TESTING_EXPORTS = ['VoiceEngineV2TestImplementation', 'VoiceEngineV2TestDriver'];
|
||||
const LEGACY_TESTING_EXPORTS = ['JsVoiceEngineV2Implementation', 'VoiceEngineV2JsDriver'];
|
||||
const TESTING_MODULE_REFERENCE_PATTERN = /from\s+['"](?:[./]*|@fluxer\/voice_engine_v2\/src\/)testing(?:\/[^'"]*)?['"]/;
|
||||
|
||||
const PUBLIC_BARRELS: ReadonlyArray<[string, Record<string, unknown>]> = [
|
||||
['src/index.ts', packageBarrel],
|
||||
['src/implementations/index.ts', implementationsBarrel],
|
||||
];
|
||||
|
||||
function readPublicExportSource(relativePath: string): string {
|
||||
return readFileSync(path.join(PACKAGE_ROOT, relativePath), 'utf8');
|
||||
}
|
||||
|
||||
describe('voice engine v2 implementation export boundary', () => {
|
||||
it('does not expose the testing substrate from resolved public barrel exports', () => {
|
||||
for (const [label, barrel] of PUBLIC_BARRELS) {
|
||||
const exportNames = Object.keys(barrel);
|
||||
expect(exportNames.length, `${label} must have runtime exports`).toBeGreaterThan(0);
|
||||
for (const exportName of QUARANTINED_TESTING_EXPORTS) {
|
||||
expect(exportNames, `${label} must not export ${exportName}`).not.toContain(exportName);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('does not reference the testing directory from public barrel sources', () => {
|
||||
for (const relativePath of PUBLIC_EXPORT_FILES) {
|
||||
const source = readPublicExportSource(relativePath);
|
||||
expect(source, `${relativePath} must not re-export from ./testing`).not.toMatch(TESTING_MODULE_REFERENCE_PATTERN);
|
||||
}
|
||||
});
|
||||
|
||||
it('does not mention quarantined or legacy testing identifiers in public barrel sources', () => {
|
||||
for (const relativePath of PUBLIC_EXPORT_FILES) {
|
||||
const source = readPublicExportSource(relativePath);
|
||||
for (const exportName of [...QUARANTINED_TESTING_EXPORTS, ...LEGACY_TESTING_EXPORTS]) {
|
||||
expect(source, `${relativePath} must not mention ${exportName}`).not.toContain(exportName);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user