Skip to content

Commit

Permalink
test: improve ssz tests consistency (#6776)
Browse files Browse the repository at this point in the history
* test: improve ssz tests consistency

* chore: address comments
  • Loading branch information
jeluard authored and philknows committed Sep 3, 2024
1 parent 55810e7 commit f83a8a1
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions packages/beacon-node/test/spec/presets/ssz_static.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import {it, vi} from "vitest";
import {expect, it, vi} from "vitest";
import {Type} from "@chainsafe/ssz";
<<<<<<< HEAD
import {ssz, sszTypesFor} from "@lodestar/types";
Expand Down Expand Up @@ -56,23 +56,26 @@ const sszStatic =
(ssz.bellatrix as Types)[typeName] ||
(ssz.altair as Types)[typeName] ||
(ssz.phase0 as Types)[typeName];
if (!sszType) {
throw Error(`No type for ${typeName}`);
}

const sszTypeNoUint = replaceUintTypeWithUintBigintType(sszType);
if (!sszType) {
expect.fail(
`Missing SSZ type definition for ${typeName}; this will prevent associated ssz_static tests to be executed`
);
} else {
const sszTypeNoUint = replaceUintTypeWithUintBigintType(sszType);

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

const testData = parseSszStaticTestcase(path.join(testSuiteDirpath, testCase));
runValidSszTest(sszTypeNoUint, testData);
});
const testData = parseSszStaticTestcase(path.join(testSuiteDirpath, testCase));
runValidSszTest(sszTypeNoUint, testData);
});
}
}
};

Expand Down

0 comments on commit f83a8a1

Please sign in to comment.