|
| 1 | +import {describe, it, expect} from "vitest"; |
| 2 | +import {ForkName, isForkExecution} from "@lodestar/params"; |
| 3 | +import {ssz} from "../../src/index.js"; |
| 4 | + |
| 5 | +describe("blinded data structures", function () { |
| 6 | + it("should have the same number of fields as non-blinded", () => { |
| 7 | + const blindedTypes = [ |
| 8 | + {a: "BlindedBeaconBlockBody" as const, b: "BeaconBlockBody" as const}, |
| 9 | + {a: "ExecutionPayloadHeader" as const, b: "ExecutionPayload" as const}, |
| 10 | + ]; |
| 11 | + |
| 12 | + for (const {a, b} of blindedTypes) { |
| 13 | + for (const fork of Object.keys(ssz.allForks) as ForkName[]) { |
| 14 | + if (!isForkExecution(fork)) { |
| 15 | + continue; |
| 16 | + } |
| 17 | + |
| 18 | + const blindedType = ssz[fork][a]; |
| 19 | + if (blindedType === undefined) { |
| 20 | + expect.fail(`fork: ${fork}, type ${a} is undefined`); |
| 21 | + } |
| 22 | + |
| 23 | + const type = ssz[fork][b]; |
| 24 | + if (type === undefined) { |
| 25 | + expect.fail(`fork: ${fork}, type ${b} is undefined`); |
| 26 | + } |
| 27 | + |
| 28 | + expect(Object.keys(blindedType.fields).length).toBeWithMessage( |
| 29 | + Object.keys(type.fields).length, |
| 30 | + `fork: ${fork}, types ${a} and ${b} have different number of fields` |
| 31 | + ); |
| 32 | + } |
| 33 | + } |
| 34 | + }); |
| 35 | +}); |
0 commit comments