Skip to content

Commit c015abc

Browse files
jeluardg11tech
authored andcommitted
test: improve ssz tests consistency (#6776)
* test: improve ssz tests consistency * chore: address comments
1 parent 274f629 commit c015abc

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

packages/beacon-node/test/spec/presets/ssz_static.test.ts

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "node:fs";
22
import path from "node:path";
3-
import {it, vi} from "vitest";
3+
import {expect, it, vi} from "vitest";
44
import {Type} from "@chainsafe/ssz";
55
import {ssz} from "@lodestar/types";
66
import {ACTIVE_PRESET, ForkName, ForkLightClient, ForkExecution} from "@lodestar/params";
@@ -56,23 +56,26 @@ const sszStatic =
5656
(ssz.bellatrix as Types)[typeName] ||
5757
(ssz.altair as Types)[typeName] ||
5858
(ssz.phase0 as Types)[typeName];
59-
if (!sszType) {
60-
throw Error(`No type for ${typeName}`);
61-
}
6259

63-
const sszTypeNoUint = replaceUintTypeWithUintBigintType(sszType);
60+
if (!sszType) {
61+
expect.fail(
62+
`Missing SSZ type definition for ${typeName}; this will prevent associated ssz_static tests to be executed`
63+
);
64+
} else {
65+
const sszTypeNoUint = replaceUintTypeWithUintBigintType(sszType);
6466

65-
for (const testCase of fs.readdirSync(testSuiteDirpath)) {
66-
// Do not manually skip tests here, do it in packages/beacon-node/test/spec/presets/index.test.ts
67-
it(testCase, function () {
68-
// Mainnet must deal with big full states and hash each one multiple times
69-
if (ACTIVE_PRESET === "mainnet") {
70-
vi.setConfig({testTimeout: 30 * 1000});
71-
}
67+
for (const testCase of fs.readdirSync(testSuiteDirpath)) {
68+
// Do not manually skip tests here, do it in packages/beacon-node/test/spec/presets/index.test.ts
69+
it(testCase, function () {
70+
// Mainnet must deal with big full states and hash each one multiple times
71+
if (ACTIVE_PRESET === "mainnet") {
72+
vi.setConfig({testTimeout: 30 * 1000});
73+
}
7274

73-
const testData = parseSszStaticTestcase(path.join(testSuiteDirpath, testCase));
74-
runValidSszTest(sszTypeNoUint, testData);
75-
});
75+
const testData = parseSszStaticTestcase(path.join(testSuiteDirpath, testCase));
76+
runValidSszTest(sszTypeNoUint, testData);
77+
});
78+
}
7679
}
7780
};
7881

0 commit comments

Comments
 (0)