Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {describe, expect, it, vi} from "vitest";
import {describe, expect, it} from "vitest";
import {
ProofType,
computeDescriptor,
Expand Down Expand Up @@ -28,8 +28,6 @@ describe("proof equivalence", () => {
}
});
it("should compute the same root from different proof types - multiple leaves", () => {
vi.setConfig({testTimeout: 10_000});

const depth = 6;
const maxIndex = 2 ** depth;
const node = createTree(depth);
Expand Down Expand Up @@ -60,7 +58,7 @@ describe("proof equivalence", () => {
}
}
}
});
}, 30_000);
});

describe("proof serialize/deserialize", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ describe("tree / getNodes", () => {
it("getNodesAtDepth", () => {
const nodes = getNodesAtDepth(tree.rootNode, depth, 0, length);
assertValidNodes(nodes, expectedNodes);
});
}, 60_000);

function assertValidNodes(nodes: Node[], expectedNodes: Node[]): void {
for (let i = 0; i < expectedNodes.length; i++) {
expect(nodes[i]).toEqualWithMessage(expectedNodes[i], `Wrong node index ${i}`);
expect(nodes[i]).toBeWithMessage(expectedNodes[i], `Wrong node index ${i}`);
}
}
});
2 changes: 1 addition & 1 deletion packages/ssz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"benchmark:local": "pnpm benchmark --local",
"test:unit": "vitest run --dir test/unit",
"test:spec": "pnpm test:spec-generic && pnpm test:spec-static test:spec-eip-4881",
"test:spec-generic": "vitest run --dir test/spec/generic",
"test:spec-generic": "vitest run --coverage.enabled=false --dir test/spec/generic",
"test:spec-static": "pnpm test:spec-static-minimal && pnpm test:spec-static-mainnet",
"test:spec-static-minimal": "LODESTAR_PRESET=minimal vitest run --dir test/spec/ test/spec/ssz_static.test.ts",
"test:spec-static-mainnet": "LODESTAR_PRESET=mainnet vitest run --dir test/spec/ test/spec/ssz_static.test.ts",
Expand Down
5 changes: 5 additions & 0 deletions packages/ssz/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ export {BitVectorType} from "./type/bitVector.ts";
export {BooleanType} from "./type/boolean.ts";
export {ByteListType} from "./type/byteList.ts";
export {ByteVectorType} from "./type/byteVector.ts";
export {CompatibleUnionType} from "./type/compatibleUnion.ts";
export {ContainerType} from "./type/container.ts";
export {ContainerNodeStructType} from "./type/containerNodeStruct.ts";
export {ListBasicType} from "./type/listBasic.ts";
export {ListCompositeType} from "./type/listComposite.ts";
export {ProgressiveBitListType} from "./type/progressiveBitList.ts";
export {ProgressiveByteListType} from "./type/progressiveByteList.ts";
export {ProgressiveContainerType} from "./type/progressiveContainer.ts";
export {ProgressiveListBasicType, ProgressiveListCompositeType} from "./type/progressiveList.ts";
export {PartialListCompositeType} from "./type/partialListComposite.ts";
export {NoneType} from "./type/none.ts";
export {UintBigintType, UintNumberType} from "./type/uint.ts";
Expand Down
3 changes: 3 additions & 0 deletions packages/ssz/src/type/bitList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ export function deserializeUint8ArrayBitListFromBytes(
if (end > data.length) {
throw Error(`BitList attempting to read byte ${end} of data length ${data.length}`);
}
if (end <= start) {
throw Error("BitList requires a padding bit");
}

const lastByte = data[end - 1];
const size = end - start;
Expand Down
Loading
Loading