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

input-output-hk / catalyst-libs / 20228814125

15 Dec 2025 10:25AM UTC coverage: 67.821% (+0.6%) from 67.194%
20228814125

Pull #709

github

web-flow
Merge 8b06de251 into 9cb603e67
Pull Request #709: chore(rust/signed-doc): Making `tests/common` module as a public mod `catalyst_signed_doc::tests_utils`

72 of 73 new or added lines in 27 files covered. (98.63%)

1 existing line in 1 file now uncovered.

14507 of 21390 relevant lines covered (67.82%)

2807.1 hits per line

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

95.0
/rust/signed_doc/src/tests_utils/mod.rs
1
//! Reusable functionality for building and signing documents
2
//! # WARNING
3
//! FOR TESTING PURPOSES ONLY, DON'T USE IN PRODUCTION CODE
4

5
#![allow(missing_docs)]
6

7
pub mod brand_parameters;
8
pub mod brand_parameters_form_template;
9
pub mod campaign_parameters;
10
pub mod campaign_parameters_form_template;
11
pub mod category_parameters;
12
pub mod category_parameters_form_template;
13
pub mod contest_ballot;
14
pub mod contest_ballot_checkpoint;
15
pub mod contest_delegation;
16
pub mod contest_parameters;
17
pub mod contest_parameters_form_template;
18
pub mod proposal;
19
pub mod proposal_comment;
20
pub mod proposal_comment_form_template;
21
pub mod proposal_form_template;
22
pub mod proposal_submission_action;
23
pub mod rep_nomination;
24
pub mod rep_nomination_form_template;
25
pub mod rep_profile;
26
pub mod rep_profile_form_template;
27

28
pub use brand_parameters::brand_parameters_doc;
29
pub use brand_parameters_form_template::brand_parameters_form_template_doc;
30
pub use campaign_parameters::campaign_parameters_doc;
31
pub use campaign_parameters_form_template::campaign_parameters_form_template_doc;
32
pub use category_parameters::category_parameters_doc;
33
pub use category_parameters_form_template::category_parameters_form_template_doc;
34
pub use contest_ballot::contest_ballot_doc;
35
pub use contest_ballot_checkpoint::contest_ballot_checkpoint_doc;
36
pub use contest_delegation::contest_delegation_doc;
37
pub use contest_parameters::contest_parameters_doc;
38
pub use contest_parameters_form_template::contest_parameters_form_template_doc;
39
pub use proposal::proposal_doc;
40
pub use proposal_comment::proposal_comment_doc;
41
pub use proposal_comment_form_template::proposal_comment_form_template_doc;
42
pub use proposal_form_template::proposal_form_template_doc;
43
pub use proposal_submission_action::proposal_submission_action_doc;
44
pub use rep_nomination::rep_nomination_doc;
45
pub use rep_nomination_form_template::rep_nomination_form_template_doc;
46
pub use rep_profile::rep_profile_doc;
47
pub use rep_profile_form_template::rep_profile_form_template_doc;
48

49
use crate::{
50
    Builder, CatalystSignedDocument, ContentType, DocumentRef,
51
    catalyst_id::{CatalystId, role_index::RoleId},
52
    providers::tests::TestCatalystProvider,
53
    uuid::{UuidV4, UuidV7},
54
};
55

56
/// # Errors
57
pub fn get_doc_kid_and_sk(
9✔
58
    provider: &TestCatalystProvider,
9✔
59
    doc: &CatalystSignedDocument,
9✔
60
    i: usize,
9✔
61
) -> anyhow::Result<(ed25519_dalek::SigningKey, CatalystId)> {
9✔
62
    let doc_kids = doc.authors();
9✔
63
    let kid = doc_kids
9✔
64
        .get(i)
9✔
65
        .ok_or(anyhow::anyhow!("does not have a kid at index '{i}'"))?;
9✔
66
    let sk = provider.get_sk(kid).ok_or(anyhow::anyhow!(
9✔
67
        "cannot find a corresponding signing key to the kid '{kid}'"
9✔
68
    ))?;
×
69
    Ok((sk.clone(), kid.clone()))
9✔
70
}
9✔
71

72
// If `None` make `CatalystId` as admin
73
#[must_use]
74
pub fn create_dummy_key_pair(role_index: RoleId) -> (ed25519_dalek::SigningKey, CatalystId) {
150✔
75
    let sk = create_signing_key();
150✔
76
    let kid = CatalystId::new("cardano", None, sk.verifying_key()).with_role(role_index);
150✔
77
    (sk, kid)
150✔
78
}
150✔
79

80
#[must_use]
81
pub fn create_dummy_admin_key_pair() -> (ed25519_dalek::SigningKey, CatalystId) {
554✔
82
    let sk = create_signing_key();
554✔
83
    let kid = CatalystId::new("cardano", None, sk.verifying_key()).as_admin();
554✔
84
    (sk, kid)
554✔
85
}
554✔
86

87
#[must_use]
88
pub fn create_signing_key() -> ed25519_dalek::SigningKey {
704✔
89
    let mut csprng = rand::rngs::OsRng;
704✔
90
    ed25519_dalek::SigningKey::generate(&mut csprng)
704✔
91
}
704✔
92

93
/// # Errors
94
pub fn create_dummy_doc_ref() -> anyhow::Result<DocumentRef> {
67✔
95
    let test_doc = Builder::new()
67✔
96
        .with_json_metadata(serde_json::json!({
67✔
97
            "id": UuidV7::new().to_string(),
67✔
98
            "ver": UuidV7::new().to_string(),
67✔
99
            "type": UuidV4::new().to_string(),
67✔
100
            "content-type": ContentType::Json,
67✔
NEW
101
        }))?
×
102
        .with_json_content(&serde_json::json!({"test": "content"}))?
67✔
103
        .build()?;
67✔
104

105
    test_doc.doc_ref()
67✔
106
}
67✔
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