forked from ChainSafe/lodestar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: align BeaconBlockBody and BlindedBeaconBlockBody (ChainSafe#6782)
* fix: align BeaconBlockBody and BlindedBeaconBlockBody * Remove type hacks in test --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {describe, it, expect} from "vitest"; | ||
import {ForkName, isForkExecution} from "@lodestar/params"; | ||
import {ssz} from "../../src/index.js"; | ||
|
||
describe("blinded data structures", function () { | ||
it("should have the same number of fields as non-blinded", () => { | ||
const blindedTypes = [ | ||
{a: "BlindedBeaconBlockBody" as const, b: "BeaconBlockBody" as const}, | ||
{a: "ExecutionPayloadHeader" as const, b: "ExecutionPayload" as const}, | ||
]; | ||
|
||
for (const {a, b} of blindedTypes) { | ||
for (const fork of Object.keys(ssz.allForks) as ForkName[]) { | ||
if (!isForkExecution(fork)) { | ||
continue; | ||
} | ||
|
||
const blindedType = ssz[fork][a]; | ||
if (blindedType === undefined) { | ||
expect.fail(`fork: ${fork}, type ${a} is undefined`); | ||
} | ||
|
||
const type = ssz[fork][b]; | ||
if (type === undefined) { | ||
expect.fail(`fork: ${fork}, type ${b} is undefined`); | ||
} | ||
|
||
expect(Object.keys(blindedType.fields).length).toBeWithMessage( | ||
Object.keys(type.fields).length, | ||
`fork: ${fork}, types ${a} and ${b} have different number of fields` | ||
); | ||
} | ||
} | ||
}); | ||
}); |