mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 16:03:20 +00:00
* fix(orchestration): preserve active workers across updates * test(ssh): model absent legacy adoption * test(orchestration): align compatibility contracts * fix(windows): escape updater PowerShell booleans * fix(windows): restore stock uninstall process check * fix(orchestration): keep recovery off renderer startup barrier * fix(orchestration): harden legacy recovery migration * fix(orchestration): close recovery review gaps * fix(orchestration): complete legacy worker cutover recovery * fix(orchestration): preserve legacy workers across updates --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
89 lines
2.6 KiB
JavaScript
89 lines
2.6 KiB
JavaScript
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { parseArgs } from './cli-args.mjs'
|
|
import { proveDistinctInstallerPair } from './installer-pair-proof.mjs'
|
|
|
|
const scratchDirs = []
|
|
|
|
async function artifactPair(fromBody = 'artifact-a', toBody = 'artifact-b') {
|
|
const directory = await mkdtemp(path.join(os.tmpdir(), 'orca-installer-pair-proof-'))
|
|
scratchDirs.push(directory)
|
|
const fromPath = path.join(directory, 'orca-a.exe')
|
|
const toPath = path.join(directory, 'orca-b.exe')
|
|
await Promise.all([writeFile(fromPath, fromBody), writeFile(toPath, toBody)])
|
|
return { fromPath, toPath }
|
|
}
|
|
|
|
afterEach(async () => {
|
|
await Promise.all(scratchDirs.splice(0).map((directory) => rm(directory, { recursive: true })))
|
|
})
|
|
|
|
describe('packaged installer pair proof', () => {
|
|
it('requires an explicit compatibility-gate flag', () => {
|
|
const opts = parseArgs([
|
|
'--from',
|
|
'a.exe',
|
|
'--to',
|
|
'b.exe',
|
|
'--expect',
|
|
'cold-restore',
|
|
'--require-distinct-artifacts'
|
|
])
|
|
|
|
expect(opts.requireDistinctArtifacts).toBe(true)
|
|
})
|
|
|
|
it('records distinct paths, versions, and hashes', async () => {
|
|
const pair = await artifactPair()
|
|
|
|
const proof = await proveDistinctInstallerPair({
|
|
...pair,
|
|
fromVersion: '1.4.130',
|
|
toVersion: '1.4.131'
|
|
})
|
|
|
|
expect(proof.from.path).not.toBe(proof.to.path)
|
|
expect(proof.from.version).not.toBe(proof.to.version)
|
|
expect(proof.from.sha256).not.toBe(proof.to.sha256)
|
|
})
|
|
|
|
it('fails closed for byte-identical artifacts at different paths', async () => {
|
|
const pair = await artifactPair('same-artifact', 'same-artifact')
|
|
|
|
await expect(
|
|
proveDistinctInstallerPair({
|
|
...pair,
|
|
fromVersion: '1.4.130',
|
|
toVersion: '1.4.131'
|
|
})
|
|
).rejects.toThrow('SHA-256 hashes are identical')
|
|
})
|
|
|
|
it('fails closed for an identical path or version', async () => {
|
|
const pair = await artifactPair()
|
|
|
|
await expect(
|
|
proveDistinctInstallerPair({
|
|
fromPath: pair.fromPath,
|
|
toPath: pair.fromPath,
|
|
fromVersion: '1.4.130',
|
|
toVersion: '1.4.130'
|
|
})
|
|
).rejects.toThrow(/paths are identical.*hashes are identical.*versions are identical/)
|
|
})
|
|
|
|
it('fails closed when either package version is unavailable', async () => {
|
|
const pair = await artifactPair()
|
|
|
|
await expect(
|
|
proveDistinctInstallerPair({
|
|
...pair,
|
|
fromVersion: null,
|
|
toVersion: '1.4.131'
|
|
})
|
|
).rejects.toThrow('both installer versions must be readable')
|
|
})
|
|
})
|