//! V1-2.3 proofs of the verification job (contract W4, V1-2 contract ยง6.5) on an in-memory
//! `VerifyBackend`: the core's verdict computed in process from the very frame the parent
//! builds (or the real child without seccomp under `test-hooks`), every child outcome mapped
//! to its closed worker code, a missing drawing judged by the core, never by the worker.
#![allow(clippy::unwrap_used, clippy::expect_used)]
use std::cell::RefCell;
use std::collections::VecDeque;
use faunosteo_core::domain::sheet::verdict::{codes as verdict_codes, sha256_hex};
use faunosteo_worker::backend::{
BackendError, BackendResult, CompleteAnswer, DrawingRow, FailAnswer, VerifyBackend,
VerifyInput, VerifyJob,
};
use faunosteo_worker::config::Config;
use faunosteo_worker::limits::VERIFY_MAX_DRAWING_BYTES;
use faunosteo_worker::run::{Mode, parse_args, verify_loop};
use faunosteo_worker::spawn::{ChildOutcome, ChildRun};
use faunosteo_worker::verifier::Verifier;
use faunosteo_worker::verify_job::{DRAWING_BUCKET, VerifyEnd, codes, process_verification};
use faunosteo_worker::watchdog::Watchdog;
use faunosteo_worker::{exit_codes, verify};
use serde_json::{Value, json};
const REVIEW: &str = "aaaaaaaa-0000-4000-8000-000000000003";
const VERSION: &str = "aaaaaaaa-0000-4000-8000-000000000002";
const SHEET: &str = "aaaaaaaa-0000-4000-8000-000000000001";
const TOKEN: &str = "30000000-0000-0000-0000-00000000000c";
const ASSET: &str = "11111111-2222-4333-8444-555555555555";
const DRAWING: &str = concat!(
"\n",
r#""#
);
fn name(text: &str) -> Value {
json!({ "fr": text, "en": text })
}
/// The core's small valid sheet (`crates/core/tests/sheet_verdict.rs::document`).
fn document() -> Value {
json!({
"schema_version": 2, "species_id": "canine", "name": name("Chien"),
"description": {}, "scope_disclaimer": { "fr": "Outil", "en": "Tool" },
"attribution": { "authors": ["A"], "license": null, "notes": null },
"vertebral_config": { "regions": [] }, "references": [],
"categories": [{ "id": "c", "name": name("C"), "color": null }],
"views": [{ "id": "main", "kind": "main", "name": name("Vue"), "svg_asset_id": ASSET, "view_box": null }],
"annotations": [{ "id": "a1", "kind": "point", "view_id": "main", "category_id": "c",
"laterality": "unpaired", "geometry": { "type": "circle", "cx": 1, "cy": 1, "r": 1 },
"review_status": "to_confirm", "name": name("P"), "finding_zone_id": "z1", "vertebral_region_code": null }],
"finding_zones": [{ "id": "z1", "name": name("Z"), "categories": [{ "id": "cat", "kind": "dysfunction",
"name": name("D"), "review_status": "to_confirm",
"children": [{ "id": "n1", "name": name("N"), "review_status": "to_confirm" }] }] }]
})
}
fn job() -> VerifyJob {
VerifyJob {
review_id: REVIEW.to_owned(),
version_id: VERSION.to_owned(),
sheet_id: SHEET.to_owned(),
revision: 3,
lease_token: TOKEN.to_owned(),
attempts: 1,
}
}
fn row() -> DrawingRow {
let sha256 = sha256_hex(DRAWING.as_bytes());
DrawingRow {
asset_id: ASSET.to_owned(),
object_key: format!("{sha256}.svg"),
sha256,
byte_size: DRAWING.len() as u64,
bucket: DRAWING_BUCKET.to_owned(),
uploaded: true,
}
}
fn input(document: String, drawings: Vec) -> VerifyInput {
VerifyInput {
review_id: REVIEW.to_owned(),
version_id: VERSION.to_owned(),
sheet_id: SHEET.to_owned(),
revision: 3,
document,
base_document: None,
drawings,
}
}
struct Fake {
calls: RefCell>,
input: RefCell