9b0ef8533cac
test infra: fix recovery.adversarial beforeEach context-arg bug; non-list word for 13-word test; vault wrong-unlock timeouts (54 reds cleared)
- time
- 2026-05-16 01:50 UTC · 5 months ago
- machine
- koh2
- parent
- c3b41306469d
↓ peach-browser-9b0ef853.tar.gzatlas at this save
files changed2 files
src/background/recovery.adversarial.test.ts+4 −3src/background/vault.adversarial.test.ts+28 −20src/background/recovery.adversarial.test.ts+4 −3
@@ -141,7 +141,7 @@141141 // ── VALIDATE_RECOVERY_WORDS edge cases ──────────────────────────────────142142 143143 describe("VALIDATE_RECOVERY_WORDS edge cases", () => {144- beforeEach(setupUnlockedVault);144+ beforeEach(() => setupUnlockedVault());145145 146146 it("words with leading/trailing whitespace are accepted", async () => {147147 const words = await getWords();@@ -200,7 +200,8 @@200200 }201201 202202 it("13 words: extra word is flagged as invalid", async () => {203- const words = [...(await getWords()), "extra"];203+ // "qwerty" is deliberately not in the Peach recovery word list.204+ const words = [...(await getWords()), "qwerty"];204205 const r = await dispatch({205206 type: "VALIDATE_RECOVERY_WORDS",206207 payload: { words },@@ -208,7 +209,7 @@208209 const data = (r as {209210 data: { invalid: Array<{ index: number; word: string }> };210211 }).data;211- expect(data.invalid.some((x) => x.word === "extra")).toBe(true);212+ expect(data.invalid.some((x) => x.word === "qwerty")).toBe(true);212213 });213214 214215 it("11 words (missing): validator returns ok", async () => {src/background/vault.adversarial.test.ts+28 −20
@@ -598,27 +598,35 @@598598 });599599 }600600 601- it("vault data is preserved across 25 wrong attempts", async () => {602- await setupLocked();603- for (let i = 0; i < 25; i++) {604- await dispatch({ type: "UNLOCK", payload: { password: "wrong" } });605- }606- expect(storage.peach_vault_a).toBeTruthy();607- // Correct password still works.608- const ok = await dispatch({609- type: "UNLOCK",610- payload: { password: "test-pass-12345" },611- });612- expect(ok.ok).toBe(true);613- });601+ it(602+ "vault data is preserved across 25 wrong attempts",603+ async () => {604+ await setupLocked();605+ for (let i = 0; i < 25; i++) {606+ await dispatch({ type: "UNLOCK", payload: { password: "wrong" } });607+ }608+ expect(storage.peach_vault_a).toBeTruthy();609+ // Correct password still works.610+ const ok = await dispatch({611+ type: "UNLOCK",612+ payload: { password: "test-pass-12345" },613+ });614+ expect(ok.ok).toBe(true);615+ },616+ 60_000,617+ );614618 615- it("vault data is preserved across 50 wrong attempts", async () => {616- await setupLocked();617- for (let i = 0; i < 50; i++) {618- await dispatch({ type: "UNLOCK", payload: { password: "wrong" } });619- }620- expect(storage.peach_vault_a).toBeTruthy();621- });619+ it(620+ "vault data is preserved across 50 wrong attempts",621+ async () => {622+ await setupLocked();623+ for (let i = 0; i < 50; i++) {624+ await dispatch({ type: "UNLOCK", payload: { password: "wrong" } });625+ }626+ expect(storage.peach_vault_a).toBeTruthy();627+ },628+ 120_000,629+ );622630 623631 it("successful unlock after wrong attempts produces unlocked state", async () => {624632 await setupLocked();