mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-30 18:12:08 -07:00
Fix verification and immersion-tracker grouping
- isolate verifier artifacts and lease handling - switch weekly/monthly tracker cutoffs to calendar boundaries - tighten boot lifecycle and zip writer tests
This commit is contained in:
@@ -5,6 +5,8 @@ import { createMainBootServices } from './services';
|
||||
test('createMainBootServices builds boot-phase service bundle', () => {
|
||||
const calls: string[] = [];
|
||||
let setPathValue: string | null = null;
|
||||
const appOnCalls: string[] = [];
|
||||
let secondInstanceHandlerRegistered = false;
|
||||
|
||||
const services = createMainBootServices({
|
||||
platform: 'linux',
|
||||
@@ -27,12 +29,17 @@ test('createMainBootServices builds boot-phase service bundle', () => {
|
||||
setPathValue = value;
|
||||
},
|
||||
quit: () => {},
|
||||
on: () => ({}),
|
||||
on: (event) => {
|
||||
appOnCalls.push(event);
|
||||
return {};
|
||||
},
|
||||
whenReady: async () => {},
|
||||
},
|
||||
shouldBypassSingleInstanceLock: () => false,
|
||||
requestSingleInstanceLockEarly: () => true,
|
||||
registerSecondInstanceHandlerEarly: () => {},
|
||||
registerSecondInstanceHandlerEarly: () => {
|
||||
secondInstanceHandlerRegistered = true;
|
||||
},
|
||||
onConfigStartupParseError: () => {
|
||||
throw new Error('unexpected parse failure');
|
||||
},
|
||||
@@ -78,6 +85,10 @@ test('createMainBootServices builds boot-phase service bundle', () => {
|
||||
mpvSocketPath: '/tmp/subminer.sock',
|
||||
texthookerPort: 5174,
|
||||
});
|
||||
assert.equal(services.appLifecycleApp.on('ready', () => {}), services.appLifecycleApp);
|
||||
assert.equal(services.appLifecycleApp.on('second-instance', () => {}), services.appLifecycleApp);
|
||||
assert.deepEqual(appOnCalls, ['ready']);
|
||||
assert.equal(secondInstanceHandlerRegistered, true);
|
||||
assert.deepEqual(calls, ['mkdir:/tmp/subminer-config']);
|
||||
assert.equal(setPathValue, '/tmp/subminer-config');
|
||||
});
|
||||
|
||||
@@ -231,10 +231,10 @@ export function createMainBootServices<
|
||||
params.registerSecondInstanceHandlerEarly(
|
||||
listener as (_event: unknown, argv: string[]) => void,
|
||||
);
|
||||
return params.app;
|
||||
return appLifecycleApp;
|
||||
}
|
||||
params.app.on(event, listener);
|
||||
return params.app;
|
||||
return appLifecycleApp;
|
||||
},
|
||||
whenReady: () => params.app.whenReady(),
|
||||
} as TAppLifecycleApp;
|
||||
|
||||
@@ -48,9 +48,14 @@ test('buildDictionaryZip writes a valid stored zip without fs.writeFileSync', ()
|
||||
const termEntries: CharacterDictionaryTermEntry[] = [
|
||||
['アルファ', 'あるふぁ', '', '', 0, ['Alpha entry'], 0, 'name'],
|
||||
];
|
||||
const originalWriteFileSync = fs.writeFileSync;
|
||||
const originalBufferConcat = Buffer.concat;
|
||||
|
||||
try {
|
||||
fs.writeFileSync = ((..._args: unknown[]) => {
|
||||
throw new Error('buildDictionaryZip should not call fs.writeFileSync');
|
||||
}) as typeof fs.writeFileSync;
|
||||
|
||||
Buffer.concat = ((...args: Parameters<typeof Buffer.concat>) => {
|
||||
throw new Error(`buildDictionaryZip should not Buffer.concat the full archive (${args[0].length} chunks)`);
|
||||
}) as typeof Buffer.concat;
|
||||
@@ -92,6 +97,7 @@ test('buildDictionaryZip writes a valid stored zip without fs.writeFileSync', ()
|
||||
assert.equal(termBank[0]?.[0], 'アルファ');
|
||||
assert.deepEqual(entries.get('images/alpha.bin'), Buffer.from([1, 2, 3]));
|
||||
} finally {
|
||||
fs.writeFileSync = originalWriteFileSync;
|
||||
Buffer.concat = originalBufferConcat;
|
||||
cleanupDir(tempDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user