mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 14:31:22 +00:00
test(coverage): share verifier-result fixtures (#16729)
This commit is contained in:
1 parent
1acbf9b4d3
commit
8de9de1dee
1 file changed
+33
-47
@@ -15,6 +15,15 @@ import {
|
||||
type ReconstructionCoverageData,
|
||||
} from "./reconstructionCoverage.js";
|
||||
|
||||
const withVerifierResults = (
|
||||
workspace: ReconstructionCoverageData,
|
||||
results: ReconstructionCoverageData["verifier_results"],
|
||||
) =>
|
||||
reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: results,
|
||||
});
|
||||
|
||||
const digest = (character: string): string => character.repeat(64);
|
||||
|
||||
it("preserves duplicate coverage owners instead of overwriting them in shared indexes", () => {
|
||||
@@ -143,13 +152,13 @@ describe("reconstruction coverage closure", () => {
|
||||
it("does not let stale verifier results satisfy current claims", () => {
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
const semantic = workspace;
|
||||
const stale = reconstructionCoverageDataFixture({
|
||||
...semantic,
|
||||
verifier_results: workspace.verifier_results.map((result) => ({
|
||||
const stale = withVerifierResults(
|
||||
semantic,
|
||||
workspace.verifier_results.map((result) => ({
|
||||
...result,
|
||||
observed_at: "2026-07-01T00:00:00.000Z",
|
||||
})),
|
||||
});
|
||||
);
|
||||
|
||||
expect(assertReconstructionCoverageEvaluation(stale)).toMatchObject({
|
||||
status: "unknown",
|
||||
@@ -259,10 +268,7 @@ describe("reconstruction coverage verifier selection", () => {
|
||||
}),
|
||||
]);
|
||||
|
||||
const missing = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [],
|
||||
});
|
||||
const missing = withVerifierResults(workspace, []);
|
||||
expect(
|
||||
assertReconstructionCoverageEvaluation(missing, boundary.boundary_id)
|
||||
.reasons,
|
||||
@@ -284,14 +290,8 @@ describe("reconstruction coverage conflicting latest verifier observations", ()
|
||||
status: "fail" as const,
|
||||
evidence_ids: [reconstructionCoverageEvidenceId("1")],
|
||||
};
|
||||
const firstPass = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [result, failed],
|
||||
});
|
||||
const firstFail = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [failed, result],
|
||||
});
|
||||
const firstPass = withVerifierResults(workspace, [result, failed]);
|
||||
const firstFail = withVerifierResults(workspace, [failed, result]);
|
||||
|
||||
const firstPassResult = assertReconstructionCoverageEvaluation(
|
||||
firstPass,
|
||||
@@ -337,14 +337,8 @@ describe("reconstruction coverage equivalent latest verifier observations", () =
|
||||
owner_sha256s: [...result.owner_sha256s].reverse(),
|
||||
evidence_ids: [reconstructionCoverageEvidenceId("1")],
|
||||
};
|
||||
const forward = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [first, equivalent],
|
||||
});
|
||||
const reversed = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [equivalent, first],
|
||||
});
|
||||
const forward = withVerifierResults(workspace, [first, equivalent]);
|
||||
const reversed = withVerifierResults(workspace, [equivalent, first]);
|
||||
const forwardResult = assertReconstructionCoverageEvaluation(
|
||||
forward,
|
||||
boundary.boundary_id,
|
||||
@@ -374,10 +368,11 @@ describe("reconstruction coverage verifier timestamp selection", () => {
|
||||
...result,
|
||||
observed_at: "2026-07-16T11:30:00.000Z",
|
||||
};
|
||||
const changed = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [result, failed, latestPass],
|
||||
});
|
||||
const changed = withVerifierResults(workspace, [
|
||||
result,
|
||||
failed,
|
||||
latestPass,
|
||||
]);
|
||||
|
||||
expect(
|
||||
assertReconstructionCoverageEvaluation(changed, boundary.boundary_id),
|
||||
@@ -387,13 +382,10 @@ describe("reconstruction coverage verifier timestamp selection", () => {
|
||||
/** Evaluate a workspace whose newest verifier observation fails the closure. */
|
||||
const expectNewestObservationFails = (passedAt: string, failedAt: string) => {
|
||||
const { workspace, result } = completeReconstructionCoverageFixture();
|
||||
const changed = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [
|
||||
{ ...result, observed_at: passedAt },
|
||||
{ ...result, observed_at: failedAt, status: "fail" },
|
||||
],
|
||||
});
|
||||
const changed = withVerifierResults(workspace, [
|
||||
{ ...result, observed_at: passedAt },
|
||||
{ ...result, observed_at: failedAt, status: "fail" },
|
||||
]);
|
||||
|
||||
expect(assertReconstructionCoverageEvaluation(changed)).toMatchObject({
|
||||
status: "failed",
|
||||
@@ -419,12 +411,9 @@ describe("reconstruction coverage verifier timestamp selection", () => {
|
||||
describe("reconstruction coverage verifier future timestamps", () => {
|
||||
it("treats an observation beyond millisecond-precision now as future", () => {
|
||||
const { workspace, result } = completeReconstructionCoverageFixture();
|
||||
const changed = reconstructionCoverageDataFixture({
|
||||
...workspace,
|
||||
verifier_results: [
|
||||
{ ...result, observed_at: "2026-07-16T12:00:00.1239Z" },
|
||||
],
|
||||
});
|
||||
const changed = withVerifierResults(workspace, [
|
||||
{ ...result, observed_at: "2026-07-16T12:00:00.1239Z" },
|
||||
]);
|
||||
|
||||
expect(
|
||||
assertReconstructionCoverageEvaluation(
|
||||
@@ -454,12 +443,9 @@ describe("reconstruction coverage verifier future timestamps", () => {
|
||||
it("rejects verifier observations from the future", () => {
|
||||
const { workspace, result } = completeReconstructionCoverageFixture();
|
||||
const semantic = workspace;
|
||||
const changed = reconstructionCoverageDataFixture({
|
||||
...semantic,
|
||||
verifier_results: [
|
||||
{ ...result, observed_at: "2026-07-17T12:00:00.000Z" },
|
||||
],
|
||||
});
|
||||
const changed = withVerifierResults(semantic, [
|
||||
{ ...result, observed_at: "2026-07-17T12:00:00.000Z" },
|
||||
]);
|
||||
|
||||
expect(assertReconstructionCoverageEvaluation(changed)).toMatchObject({
|
||||
status: "unknown",
|
||||
|
||||
Reference in new issue
Block a user