• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / catalyst-libs / 15780345914

20 Jun 2025 01:43PM UTC coverage: 67.359%. First build
15780345914

Pull #368

github

web-flow
Merge f4dccb56a into 8460d7899
Pull Request #368: fix(rust/signed-doc): Apply new document ref and fix validation rules

464 of 481 new or added lines in 13 files covered. (96.47%)

12580 of 18676 relevant lines covered (67.36%)

2137.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.67
/rust/signed_doc/src/validator/utils.rs
1
//! Validation utility functions
2

3
use catalyst_types::problem_report::ProblemReport;
4

5
use crate::{providers::CatalystSignedDocumentProvider, CatalystSignedDocument, DocumentRef};
6

7
/// A helper validation document function, which validates a document from the
8
/// `ValidationDataProvider`.
9
pub(crate) async fn validate_provided_doc<Provider, Validator>(
61✔
10
    doc_ref: &DocumentRef, provider: &Provider, report: &ProblemReport, validator: Validator,
61✔
11
) -> anyhow::Result<bool>
61✔
12
where
61✔
13
    Provider: CatalystSignedDocumentProvider,
61✔
14
    Validator: Fn(CatalystSignedDocument) -> bool,
61✔
15
{
61✔
16
    const CONTEXT: &str = "Validation data provider";
17

18
    // General check for document ref
19

20
    // Getting the Signed Document instance from a doc ref.
21
    // The reference document must exist
22
    if let Some(doc) = provider.try_get_doc(doc_ref).await? {
61✔
23
        let id = doc
48✔
24
            .doc_id()
48✔
25
            .inspect_err(|_| report.missing_field("id", CONTEXT))?;
48✔
26

27
        let ver = doc
48✔
28
            .doc_ver()
48✔
29
            .inspect_err(|_| report.missing_field("ver", CONTEXT))?;
48✔
30
        // id and version must match the values in ref doc
31
        if &id != doc_ref.id() && &ver != doc_ref.ver() {
48✔
NEW
32
            report.invalid_value(
×
NEW
33
                "id and version",
×
NEW
34
                &format!("id: {id}, ver: {ver}"),
×
NEW
35
                &format!("id: {}, ver: {}", doc_ref.id(), doc_ref.ver()),
×
NEW
36
                CONTEXT,
×
NEW
37
            );
×
NEW
38
            return Ok(false);
×
39
        }
48✔
40
        Ok(validator(doc))
48✔
41
    } else {
42
        report.functional_validation(
13✔
43
            format!("Cannot retrieve a document {doc_ref}").as_str(),
13✔
44
            CONTEXT,
13✔
45
        );
13✔
46
        Ok(false)
13✔
47
    }
48
}
61✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc