Update tests to cover blobs arrays of length zero and one

This commit is contained in:
dancoffman 2022-11-08 12:53:36 -08:00
parent 0e474e6ec4
commit 6c50c40247
No known key found for this signature in database
GPG Key ID: 47B1F53E36A9B3CC
1 changed files with 10 additions and 10 deletions

View File

@ -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);