From 6c50c402476ff3a4c69bad41764b1f762df887c3 Mon Sep 17 00:00:00 2001 From: dancoffman Date: Tue, 8 Nov 2022 12:53:36 -0800 Subject: [PATCH] Update tests to cover blobs arrays of length zero and one --- bindings/node.js/test.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bindings/node.js/test.ts b/bindings/node.js/test.ts index 89362eb..da4ecc3 100644 --- a/bindings/node.js/test.ts +++ b/bindings/node.js/test.ts @@ -37,19 +37,19 @@ describe("C-KZG", () => { expect(verifyAggregateKzgProof(blobs, commitments, proof)).toBe(true); }); - it("computes the aggregate proof when blobs is an empty array", () => { - const proof = computeAggregateKzgProof([]); - - // Is this actually what the aggregate proof for an empty array should be? - expect(proof.toString()).toEqual( - [ - 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - ].toString(), + it("throws an error when blobs is an empty array", () => { + expect(() => computeAggregateKzgProof([])).toThrowError( + "Failed to compute proof", ); }); + it("computes the aggregate proof when for a single blob", () => { + let blobs = new Array(1).fill(0).map(generateRandomBlob); + let commitments = blobs.map(blobToKzgCommitment); + let proof = computeAggregateKzgProof(blobs); + expect(verifyAggregateKzgProof(blobs, commitments, proof)).toBe(true); + }); + it("fails when given incorrect commitments", () => { const blobs = new Array(2).fill(0).map(generateRandomBlob); const commitments = blobs.map(blobToKzgCommitment);