Skip to content
Open
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
2 changes: 2 additions & 0 deletions packages/beacon-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
"test:sim": "vitest run test/sim/**/*.test.ts",
"test:sim:blobs": "vitest run test/sim/4844-interop.test.ts",
"download-spec-tests": "node --loader=ts-node/esm test/spec/downloadTests.ts",
"download-compliance-fc-tests": "../../scripts/download-compliance-fc-tests.sh",
"test:spec:compliance-fc": "../../scripts/compliance-fc-report.sh",
"test:spec:bls": "vitest run --project spec-minimal test/spec/bls/",
"test:spec:general": "vitest run --project spec-minimal test/spec/general/",
"test:spec:minimal": "vitest run --project spec-minimal test/spec/presets/",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import fs from "node:fs";
import path from "node:path";
import {describe, it} from "vitest";
import {ACTIVE_PRESET} from "@lodestar/params";
import {complianceForkChoiceSpecTests} from "../specTestVersioning.js";
import {forkChoiceTest} from "../utils/forkChoiceRunner.js";
import {specTestIterator} from "../utils/specTestIterator.js";
import {RunnerType} from "../utils/types.js";

// Compliance fork choice tests share the standard spec-test layout under each
// config archive (verified against the `small.tar.gz` artifact from the
// consensus-specs "Compliance Tests" workflow):
//
// spec-tests-compliance/<config>/tests/<preset>/<fork>/fork_choice_compliance/<handler>/<suite>/<case>/
//
// We reuse `specTestIterator` and register a runner under the name
// `fork_choice_compliance` (consensus-specs naming, not Prysm's
// `compliance_fork_choice`). Each config gets a `compliance_fork_choice/<config>/`
// prefix on its test IDs so reports can differentiate when multiple configs
// are extracted side-by-side.

for (const configName of complianceForkChoiceSpecTests.configs) {
const configRoot = path.join(complianceForkChoiceSpecTests.outputDir, configName);

if (!fs.existsSync(configRoot)) {
describe(`compliance_fork_choice/${configName}`, () => {
it.skip(
`compliance test data not present at ${configRoot}; ` +
`run \`./scripts/download-compliance-fc-tests.sh --config ${configName}\` to fetch`,
() => {}
);
});
continue;
}

// The published artifact extracts to `<config>/tests/<preset>/...` but allow a
// flatter `<config>/<preset>/...` layout in case future tarballs drop the prefix.
const presetRoot = [path.join(configRoot, "tests", ACTIVE_PRESET), path.join(configRoot, ACTIVE_PRESET)].find((p) =>
fs.existsSync(p)
);

if (presetRoot === undefined) {
describe(`compliance_fork_choice/${configName}/${ACTIVE_PRESET}`, () => {
it.skip(`compliance ${configName} archive does not contain preset ${ACTIVE_PRESET}`, () => {});
});
continue;
}

specTestIterator(
presetRoot,
{
fork_choice_compliance: {
type: RunnerType.default,
fn: forkChoiceTest({onlyPredefinedResponses: false}),
},
},
undefined,
`compliance_fork_choice/${configName}/`
);
}
Loading