bun test v1.4.4 (38afee6c8)

student-tests/git-tracking-proof.test.ts:
(pass) actual producer output is accepted only for matching pinned bytes and current source [0.39ms]
2 | import{createGitProofProducer,createGitProofReader,proofHash,type SourceHashes}from"../scripts/git-tracking-proof";
3 | const files:SourceHashes={"scripts/example.ts":"a".repeat(64)};
4 | async function produced(){return createGitProofProducer({query:async()=>({code:0,stdout:""}),head:async()=>"b".repeat(40),snapshot:async()=>({...files})})("/fixture/canonical");}
5 | const bytes=(p:unknown)=>Buffer.from(JSON.stringify(p));
6 | test("actual producer output is accepted only for matching pinned bytes and current source",async()=>{const p=bytes(await produced());const r=await createGitProofReader({read:async()=>p,snapshot:async()=>({...files})})(proofHash(p));expect(r.tracked_private_files).toBe(0);expect(r.proof_sha256).toBe(proofHash(p));});
7 | test("changed proof bytes are rejected before source inspection",async()=>{const p=bytes(await produced());let calls=0;await expect(createGitProofReader({read:async()=>Buffer.concat([p,Buffer.from(" ")]),snapshot:async()=>{calls++;return files;}})(proofHash(p))).rejects.toThrow("GIT_PROOF_SHA_MISMATCH");expect(calls).toBe(0);});
                                                                                                                                                                                                                                                                                   ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/git-tracking-proof.test.ts:7:272)
(fail) changed proof bytes are rejected before source inspection [0.52ms]
(pass) missing proof preserves the primary read failure [0.05ms]
4 | async function produced(){return createGitProofProducer({query:async()=>({code:0,stdout:""}),head:async()=>"b".repeat(40),snapshot:async()=>({...files})})("/fixture/canonical");}
5 | const bytes=(p:unknown)=>Buffer.from(JSON.stringify(p));
6 | test("actual producer output is accepted only for matching pinned bytes and current source",async()=>{const p=bytes(await produced());const r=await createGitProofReader({read:async()=>p,snapshot:async()=>({...files})})(proofHash(p));expect(r.tracked_private_files).toBe(0);expect(r.proof_sha256).toBe(proofHash(p));});
7 | test("changed proof bytes are rejected before source inspection",async()=>{const p=bytes(await produced());let calls=0;await expect(createGitProofReader({read:async()=>Buffer.concat([p,Buffer.from(" ")]),snapshot:async()=>{calls++;return files;}})(proofHash(p))).rejects.toThrow("GIT_PROOF_SHA_MISMATCH");expect(calls).toBe(0);});
8 | test("missing proof preserves the primary read failure",async()=>{const error=new Error("FIXTURE_MISSING_PROOF");let actual:unknown;try{await createGitProofReader({read:async()=>{throw error;},snapshot:async()=>files})("c".repeat(64));}catch(e){actual=e;}expect(actual).toBe(error);});
9 | test.each([{name:"changed source bytes",current:{"scripts/example.ts":"c".repeat(64)}},{name:"added source entry",current:{...files,"scripts/new.ts":"d".repeat(64)}}])("$name invalidates canonical Git evidence",async({current})=>{const p=bytes(await produced());await expect(createGitProofReader({read:async()=>p,snapshot:async()=>current})(proofHash(p))).rejects.toThrow("GIT_PROOF_SOURCE_MISMATCH");});
                                                                                                                                                                                                                                                                                                                                                                                ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/git-tracking-proof.test.ts:9:365)
(fail) changed source bytes invalidates canonical Git evidence [0.10ms]
4 | async function produced(){return createGitProofProducer({query:async()=>({code:0,stdout:""}),head:async()=>"b".repeat(40),snapshot:async()=>({...files})})("/fixture/canonical");}
5 | const bytes=(p:unknown)=>Buffer.from(JSON.stringify(p));
6 | test("actual producer output is accepted only for matching pinned bytes and current source",async()=>{const p=bytes(await produced());const r=await createGitProofReader({read:async()=>p,snapshot:async()=>({...files})})(proofHash(p));expect(r.tracked_private_files).toBe(0);expect(r.proof_sha256).toBe(proofHash(p));});
7 | test("changed proof bytes are rejected before source inspection",async()=>{const p=bytes(await produced());let calls=0;await expect(createGitProofReader({read:async()=>Buffer.concat([p,Buffer.from(" ")]),snapshot:async()=>{calls++;return files;}})(proofHash(p))).rejects.toThrow("GIT_PROOF_SHA_MISMATCH");expect(calls).toBe(0);});
8 | test("missing proof preserves the primary read failure",async()=>{const error=new Error("FIXTURE_MISSING_PROOF");let actual:unknown;try{await createGitProofReader({read:async()=>{throw error;},snapshot:async()=>files})("c".repeat(64));}catch(e){actual=e;}expect(actual).toBe(error);});
9 | test.each([{name:"changed source bytes",current:{"scripts/example.ts":"c".repeat(64)}},{name:"added source entry",current:{...files,"scripts/new.ts":"d".repeat(64)}}])("$name invalidates canonical Git evidence",async({current})=>{const p=bytes(await produced());await expect(createGitProofReader({read:async()=>p,snapshot:async()=>current})(proofHash(p))).rejects.toThrow("GIT_PROOF_SOURCE_MISMATCH");});
                                                                                                                                                                                                                                                                                                                                                                                ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/git-tracking-proof.test.ts:9:365)
(fail) added source entry invalidates canonical Git evidence [0.04ms]
 5 | const bytes=(p:unknown)=>Buffer.from(JSON.stringify(p));
 6 | test("actual producer output is accepted only for matching pinned bytes and current source",async()=>{const p=bytes(await produced());const r=await createGitProofReader({read:async()=>p,snapshot:async()=>({...files})})(proofHash(p));expect(r.tracked_private_files).toBe(0);expect(r.proof_sha256).toBe(proofHash(p));});
 7 | test("changed proof bytes are rejected before source inspection",async()=>{const p=bytes(await produced());let calls=0;await expect(createGitProofReader({read:async()=>Buffer.concat([p,Buffer.from(" ")]),snapshot:async()=>{calls++;return files;}})(proofHash(p))).rejects.toThrow("GIT_PROOF_SHA_MISMATCH");expect(calls).toBe(0);});
 8 | test("missing proof preserves the primary read failure",async()=>{const error=new Error("FIXTURE_MISSING_PROOF");let actual:unknown;try{await createGitProofReader({read:async()=>{throw error;},snapshot:async()=>files})("c".repeat(64));}catch(e){actual=e;}expect(actual).toBe(error);});
 9 | test.each([{name:"changed source bytes",current:{"scripts/example.ts":"c".repeat(64)}},{name:"added source entry",current:{...files,"scripts/new.ts":"d".repeat(64)}}])("$name invalidates canonical Git evidence",async({current})=>{const p=bytes(await produced());await expect(createGitProofReader({read:async()=>p,snapshot:async()=>current})(proofHash(p))).rejects.toThrow("GIT_PROOF_SOURCE_MISMATCH");});
10 | test("nonempty private tracking query result never becomes a zero-count proof",async()=>{const p=await produced();p.result.stdout_base64=Buffer.from(".env\0").toString("base64");const b=bytes(p);await expect(createGitProofReader({read:async()=>b,snapshot:async()=>files})(proofHash(b))).rejects.toThrow("GIT_PROOF_INVALID");});
                                                                                                                                                                                                                                                                                                            ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/git-tracking-proof.test.ts:10:296)
(fail) nonempty private tracking query result never becomes a zero-count proof [0.24ms]
 6 | test("actual producer output is accepted only for matching pinned bytes and current source",async()=>{const p=bytes(await produced());const r=await createGitProofReader({read:async()=>p,snapshot:async()=>({...files})})(proofHash(p));expect(r.tracked_private_files).toBe(0);expect(r.proof_sha256).toBe(proofHash(p));});
 7 | test("changed proof bytes are rejected before source inspection",async()=>{const p=bytes(await produced());let calls=0;await expect(createGitProofReader({read:async()=>Buffer.concat([p,Buffer.from(" ")]),snapshot:async()=>{calls++;return files;}})(proofHash(p))).rejects.toThrow("GIT_PROOF_SHA_MISMATCH");expect(calls).toBe(0);});
 8 | test("missing proof preserves the primary read failure",async()=>{const error=new Error("FIXTURE_MISSING_PROOF");let actual:unknown;try{await createGitProofReader({read:async()=>{throw error;},snapshot:async()=>files})("c".repeat(64));}catch(e){actual=e;}expect(actual).toBe(error);});
 9 | test.each([{name:"changed source bytes",current:{"scripts/example.ts":"c".repeat(64)}},{name:"added source entry",current:{...files,"scripts/new.ts":"d".repeat(64)}}])("$name invalidates canonical Git evidence",async({current})=>{const p=bytes(await produced());await expect(createGitProofReader({read:async()=>p,snapshot:async()=>current})(proofHash(p))).rejects.toThrow("GIT_PROOF_SOURCE_MISMATCH");});
10 | test("nonempty private tracking query result never becomes a zero-count proof",async()=>{const p=await produced();p.result.stdout_base64=Buffer.from(".env\0").toString("base64");const b=bytes(p);await expect(createGitProofReader({read:async()=>b,snapshot:async()=>files})(proofHash(b))).rejects.toThrow("GIT_PROOF_INVALID");});
11 | test("a weakened query cannot prove the original private-file patterns",async()=>{const p=await produced();p.query.pop();const b=bytes(p);await expect(createGitProofReader({read:async()=>b,snapshot:async()=>files})(proofHash(b))).rejects.toThrow("GIT_PROOF_INVALID");});
                                                                                                                                                                                                                                                   ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/git-tracking-proof.test.ts:11:239)
(fail) a weakened query cannot prove the original private-file patterns [0.07ms]
 7 | test("changed proof bytes are rejected before source inspection",async()=>{const p=bytes(await produced());let calls=0;await expect(createGitProofReader({read:async()=>Buffer.concat([p,Buffer.from(" ")]),snapshot:async()=>{calls++;return files;}})(proofHash(p))).rejects.toThrow("GIT_PROOF_SHA_MISMATCH");expect(calls).toBe(0);});
 8 | test("missing proof preserves the primary read failure",async()=>{const error=new Error("FIXTURE_MISSING_PROOF");let actual:unknown;try{await createGitProofReader({read:async()=>{throw error;},snapshot:async()=>files})("c".repeat(64));}catch(e){actual=e;}expect(actual).toBe(error);});
 9 | test.each([{name:"changed source bytes",current:{"scripts/example.ts":"c".repeat(64)}},{name:"added source entry",current:{...files,"scripts/new.ts":"d".repeat(64)}}])("$name invalidates canonical Git evidence",async({current})=>{const p=bytes(await produced());await expect(createGitProofReader({read:async()=>p,snapshot:async()=>current})(proofHash(p))).rejects.toThrow("GIT_PROOF_SOURCE_MISMATCH");});
10 | test("nonempty private tracking query result never becomes a zero-count proof",async()=>{const p=await produced();p.result.stdout_base64=Buffer.from(".env\0").toString("base64");const b=bytes(p);await expect(createGitProofReader({read:async()=>b,snapshot:async()=>files})(proofHash(b))).rejects.toThrow("GIT_PROOF_INVALID");});
11 | test("a weakened query cannot prove the original private-file patterns",async()=>{const p=await produced();p.query.pop();const b=bytes(p);await expect(createGitProofReader({read:async()=>b,snapshot:async()=>files})(proofHash(b))).rejects.toThrow("GIT_PROOF_INVALID");});
12 | test("producer rejects a changing HEAD during capture",async()=>{let reads=0;await expect(createGitProofProducer({query:async()=>({code:0,stdout:""}),head:async()=>++reads===1?"b".repeat(40):"c".repeat(40),snapshot:async()=>files})("/fixture/canonical")).rejects.toThrow("GIT_CAPTURE_CHANGED");});
                                                                                                                                                                                                                                                                            ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/git-tracking-proof.test.ts:12:264)
(fail) producer rejects a changing HEAD during capture [0.07ms]
 8 | test("missing proof preserves the primary read failure",async()=>{const error=new Error("FIXTURE_MISSING_PROOF");let actual:unknown;try{await createGitProofReader({read:async()=>{throw error;},snapshot:async()=>files})("c".repeat(64));}catch(e){actual=e;}expect(actual).toBe(error);});
 9 | test.each([{name:"changed source bytes",current:{"scripts/example.ts":"c".repeat(64)}},{name:"added source entry",current:{...files,"scripts/new.ts":"d".repeat(64)}}])("$name invalidates canonical Git evidence",async({current})=>{const p=bytes(await produced());await expect(createGitProofReader({read:async()=>p,snapshot:async()=>current})(proofHash(p))).rejects.toThrow("GIT_PROOF_SOURCE_MISMATCH");});
10 | test("nonempty private tracking query result never becomes a zero-count proof",async()=>{const p=await produced();p.result.stdout_base64=Buffer.from(".env\0").toString("base64");const b=bytes(p);await expect(createGitProofReader({read:async()=>b,snapshot:async()=>files})(proofHash(b))).rejects.toThrow("GIT_PROOF_INVALID");});
11 | test("a weakened query cannot prove the original private-file patterns",async()=>{const p=await produced();p.query.pop();const b=bytes(p);await expect(createGitProofReader({read:async()=>b,snapshot:async()=>files})(proofHash(b))).rejects.toThrow("GIT_PROOF_INVALID");});
12 | test("producer rejects a changing HEAD during capture",async()=>{let reads=0;await expect(createGitProofProducer({query:async()=>({code:0,stdout:""}),head:async()=>++reads===1?"b".repeat(40):"c".repeat(40),snapshot:async()=>files})("/fixture/canonical")).rejects.toThrow("GIT_CAPTURE_CHANGED");});
13 | test("producer rejects a changing source snapshot",async()=>{let reads=0;await expect(createGitProofProducer({query:async()=>({code:0,stdout:""}),head:async()=>"b".repeat(40),snapshot:async()=>++reads===1?files:{"scripts/example.ts":"c".repeat(64)}})("/fixture/canonical")).rejects.toThrow("GIT_CAPTURE_CHANGED");});
                                                                                                                                                                                                                                                                                               ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/git-tracking-proof.test.ts:13:283)
(fail) producer rejects a changing source snapshot [0.06ms]

 2 pass
 7 fail
 10 expect() calls
Ran 9 tests across 1 file. [16.00ms]
