Public: anyone can read this; the crew can change it.
Full suite red: test/offsite-lane.test.ts #12685
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/12653-full-suite-red-test-offsite-lane-test-ts → main 1 commit fork
1 file
changed +14
−6
test/offsite-lane.test.ts +14 −6
| @@ -173,16 +173,21 @@ describe("the off-site lane end to end", () => { | ||
| 173 | 173 | await rm(root, { recursive: true, force: true }); |
| 174 | 174 | }); |
| 175 | 175 | |
| 176 | test("the pass seals every object, a restore with the passphrase brings the forge back, and the drill restores from it", async () => { | |
| 177 | const mirror = sealedStore(dirStore(offDir), PASS); | |
| 178 | const svc = startSnapshots(app, dirStore(join(root, "primary")), { | |
| 176 | let mirror: Store; | |
| 177 | let svc: ReturnType<typeof startSnapshots>; | |
| 178 | let m: Awaited<ReturnType<typeof svc.now>>; | |
| 179 | let onBucket: string[]; | |
| 180 | ||
| 181 | test("the pass seals every object under names that hide every path", async () => { | |
| 182 | mirror = sealedStore(dirStore(offDir), PASS); | |
| 183 | svc = startSnapshots(app, dirStore(join(root, "primary")), { | |
| 179 | 184 | version: "t", |
| 180 | 185 | nightly: false, |
| 181 | 186 | passphrase: PASS, |
| 182 | 187 | mirror, |
| 183 | 188 | drill: (deps) => runDrill({ ...deps, boot: async () => ({ ok: true, reason: "" }) }), |
| 184 | 189 | }); |
| 185 | const m = await svc.now(); | |
| 190 | m = await svc.now(); | |
| 186 | 191 | const state = await svc.mirrorFresh(); |
| 187 | 192 | expect(state?.failingSince).toBeUndefined(); |
| 188 | 193 | expect(state?.sealed).toBe(true); |
| @@ -190,7 +195,7 @@ describe("the off-site lane end to end", () => { | ||
| 190 | 195 | |
| 191 | 196 | // On the bucket: only `sealed/chunks/<hmac>` and the manifest as |
| 192 | 197 | // `sealed/snapshots/<name>/<hmac>`, and not one plain byte of the database or the manifest. |
| 193 | const onBucket = files(offDir); | |
| 198 | onBucket = files(offDir); | |
| 194 | 199 | // Every chunk the snapshot names, its manifest, and the lane's header. |
| 195 | 200 | const ids = [...new Set(m.files.flatMap((f) => f.chunks ?? []))]; |
| 196 | 201 | expect(onBucket.length).toBe(ids.length + 2); |
| @@ -205,7 +210,9 @@ describe("the off-site lane end to end", () => { | ||
| 205 | 210 | expect(raw).not.toContain("SQLite format"); |
| 206 | 211 | expect(raw).not.toContain('"startedAt"'); |
| 207 | 212 | } |
| 213 | }, 60_000); | |
| 208 | 214 | |
| 215 | test("a restore with the passphrase brings the forge back; another passphrase opens nothing", async () => { | |
| 209 | 216 | // The lane lists and restores like any store, given the passphrase; another passphrase opens nothing. |
| 210 | 217 | expect((await listSnapshots(mirror)).map((x) => x.name)).toEqual([m.name]); |
| 211 | 218 | const target = join(root, "restored"); |
| @@ -219,8 +226,9 @@ describe("the off-site lane end to end", () => { | ||
| 219 | 226 | const sealedFile = onBucket.find((f) => relative(offDir, f) !== LANE_HEADER)!; |
| 220 | 227 | const wrong = await sealKeys("wrong", header.salt); |
| 221 | 228 | expect(() => openBody(wrong, readFileSync(sealedFile), "x")).toThrow("wrong passphrase"); |
| 229 | }, 60_000); | |
| 222 | 230 | |
| 223 | // The drill restores the newest off-site snapshot, green, and keeps where it came from. | |
| 231 | test("the drill restores the newest off-site snapshot and keeps where it came from", async () => { | |
| 224 | 232 | const d = await svc.drill(); |
| 225 | 233 | expect(d.verdict).toBe("green"); |
| 226 | 234 | expect(d.snapshotId).toBe(m.name); |
new above
offline