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

input-output-hk / catalyst-libs / 16646523141

31 Jul 2025 10:28AM UTC coverage: 67.341% (+3.8%) from 63.544%
16646523141

push

github

web-flow
feat(rust/signed-doc): Implement new Catalyst Signed Doc (#338)

* chore: add new line to open pr

Signed-off-by: bkioshn <bkioshn@gmail.com>

* chore: revert

Signed-off-by: bkioshn <bkioshn@gmail.com>

* feat(rust/signed-doc): add new type `DocType` (#339)

* feat(signed-doc): add new type DocType

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): add conversion policy

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): doc type

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): doc type error

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): seperate test

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): format

Signed-off-by: bkioshn <bkioshn@gmail.com>

---------

Signed-off-by: bkioshn <bkioshn@gmail.com>

* feat(rust/signed-doc): Add initial decoding tests for the Catalyst Signed Documents (#349)

* wip

* wip

* fix fmt

* fix spelling

* fix clippy

* fix(rust/signed-doc): Apply new `DocType` (#347)

* feat(signed-doc): add new type DocType

Signed-off-by: bkioshn <bkioshn@gmail.com>

* wip: apply doctype

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): add more function to DocType

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): map old doctype to new doctype

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): add eq to uuidv4

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): fix validator

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): minor fixes

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(catalyst-types): add hash to uuidv4

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): decoding test

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): doctype

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(signed-doc): minor fixes

Signed-off-by: bkioshn <bkioshn@gmail.com>

* chore(sign-doc): fix comment

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix(catalyst-types): add froms... (continued)

2453 of 2675 new or added lines in 38 files covered. (91.7%)

19 existing lines in 7 files now uncovered.

11312 of 16798 relevant lines covered (67.34%)

2525.16 hits per line

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

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

3
use catalyst_types::problem_report::ProblemReport;
4

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

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

20
    // General check for document ref
21

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

29
        let ver = doc
67✔
30
            .doc_ver()
67✔
31
            .inspect_err(|_| report.missing_field("ver", CONTEXT))?;
67✔
32
        // id and version must match the values in ref doc
33
        if &id != doc_ref.id() && &ver != doc_ref.ver() {
67✔
NEW
34
            report.invalid_value(
×
NEW
35
                "id and version",
×
NEW
36
                &format!("id: {id}, ver: {ver}"),
×
NEW
37
                &format!("id: {}, ver: {}", doc_ref.id(), doc_ref.ver()),
×
NEW
38
                CONTEXT,
×
39
            );
NEW
40
            return Ok(false);
×
41
        }
67✔
42
        Ok(validator(doc))
67✔
43
    } else {
44
        report.functional_validation(
8✔
45
            format!("Cannot retrieve a document {doc_ref}").as_str(),
8✔
46
            CONTEXT,
8✔
47
        );
48
        Ok(false)
8✔
49
    }
50
}
75✔
51

52
/// Validate the document references
53
/// Document all possible error in doc report (no fail fast)
54
pub(crate) async fn validate_doc_refs<Provider, Validator>(
72✔
55
    doc_refs: &DocumentRefs, provider: &Provider, report: &ProblemReport, validator: Validator,
72✔
56
) -> anyhow::Result<bool>
72✔
57
where
72✔
58
    Provider: CatalystSignedDocumentProvider,
72✔
59
    Validator: Fn(CatalystSignedDocument) -> bool,
72✔
60
{
72✔
61
    let mut all_valid = true;
72✔
62

63
    for dr in doc_refs.doc_refs() {
75✔
64
        let is_valid = validate_provided_doc(dr, provider, report, &validator).await?;
75✔
65
        if !is_valid {
75✔
66
            all_valid = false;
28✔
67
        }
47✔
68
    }
69
    Ok(all_valid)
72✔
70
}
72✔
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

© 2025 Coveralls, Inc