Skip to content

Commit 36677cd

Browse files
committed
wip
1 parent 6e338cb commit 36677cd

File tree

9 files changed

+167
-261
lines changed

9 files changed

+167
-261
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
use super::*;
22

33
pub fn brand_parameters_doc() -> anyhow::Result<CatalystSignedDocument> {
4-
let doc = Builder::new()
4+
Builder::new()
55
.with_json_metadata(serde_json::json!({
66
"content-type": ContentType::Json.to_string(),
77
"id": UuidV7::new(),
88
"ver": UuidV7::new(),
99
"type": doc_types::BRAND_PARAMETERS.clone(),
1010
}))?
1111
.empty_content()?
12-
.build()?;
13-
Ok(doc)
12+
.build()
1413
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
use super::*;
22

33
pub fn campaign_parameters_doc() -> anyhow::Result<CatalystSignedDocument> {
4-
let doc = Builder::new()
4+
Builder::new()
55
.with_json_metadata(serde_json::json!({
66
"content-type": ContentType::Json.to_string(),
77
"id": UuidV7::new(),
88
"ver": UuidV7::new(),
99
"type": doc_types::CAMPAIGN_PARAMETERS.clone(),
1010
}))?
1111
.empty_content()?
12-
.build()?;
13-
Ok(doc)
12+
.build()
1413
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
use super::*;
22

33
pub fn category_parameters_doc() -> anyhow::Result<CatalystSignedDocument> {
4-
let doc = Builder::new()
4+
Builder::new()
55
.with_json_metadata(serde_json::json!({
66
"content-type": ContentType::Json.to_string(),
77
"id": UuidV7::new(),
88
"ver": UuidV7::new(),
99
"type": doc_types::CATEGORY_PARAMETERS.clone(),
1010
}))?
1111
.empty_content()?
12-
.build()?;
13-
Ok(doc)
12+
.build()
1413
}

rust/signed_doc/tests/common/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
pub mod brand_parameters;
44
pub mod campaign_parameters;
55
pub mod category_parameters;
6-
pub mod dummies;
76
pub mod proposal;
7+
pub mod proposal_comment;
88
pub mod proposal_comment_form_template;
99
pub mod proposal_form_template;
1010
pub mod proposal_submission_action;
@@ -17,6 +17,7 @@ use catalyst_signed_doc::*;
1717
use catalyst_types::catalyst_id::role_index::RoleId;
1818
pub use category_parameters::category_parameters_doc;
1919
pub use proposal::proposal_doc;
20+
pub use proposal_comment::proposal_comment_doc;
2021
pub use proposal_comment_form_template::proposal_comment_form_template_doc;
2122
pub use proposal_form_template::proposal_form_template_doc;
2223
pub use proposal_submission_action::proposal_submission_action_doc;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use catalyst_signed_doc::providers::tests::TestCatalystProvider;
2+
use ed25519_dalek::ed25519::signature::Signer;
3+
4+
use super::*;
5+
6+
/// Creates a Proposal Comment doc, without reply metadata field
7+
pub fn proposal_comment_doc(
8+
ref_doc: &CatalystSignedDocument,
9+
template_doc: &CatalystSignedDocument,
10+
parameters_doc: &CatalystSignedDocument,
11+
provider: &mut TestCatalystProvider,
12+
) -> anyhow::Result<CatalystSignedDocument> {
13+
let id = UuidV7::new();
14+
let (sk, _, kid) = create_dummy_key_pair(RoleId::Role0)
15+
.inspect(|(_, pk, kid)| provider.add_pk(kid.clone(), pk.clone()))?;
16+
Builder::new()
17+
.with_json_metadata(serde_json::json!({
18+
"content-type": ContentType::Json.to_string(),
19+
"content-encoding": ContentEncoding::Brotli.to_string(),
20+
"type": doc_types::PROPOSAL_COMMENT.clone(),
21+
"id": id,
22+
"ver": id,
23+
"ref": {
24+
"id": ref_doc.doc_id()?,
25+
"ver": ref_doc.doc_ver()?,
26+
},
27+
"template": {
28+
"id": template_doc.doc_id()?,
29+
"ver": template_doc.doc_ver()?,
30+
},
31+
"parameters": {
32+
"id": parameters_doc.doc_id()?,
33+
"ver": parameters_doc.doc_ver()?,
34+
}
35+
}))?
36+
.with_json_content(&serde_json::json!({}))?
37+
.add_signature(|m| sk.sign(&m).to_vec(), kid)?
38+
.build()
39+
}

rust/signed_doc/tests/common/proposal_comment_form_template.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
pub fn proposal_comment_form_template_doc(
44
parameters_doc: &CatalystSignedDocument
55
) -> anyhow::Result<CatalystSignedDocument> {
6-
let doc = Builder::new()
6+
Builder::new()
77
.with_json_metadata(serde_json::json!({
88
"content-type": ContentType::Json.to_string(),
99
"content-encoding": ContentEncoding::Brotli.to_string(),
@@ -15,13 +15,6 @@ pub fn proposal_comment_form_template_doc(
1515
"ver": parameters_doc.doc_ver()?,
1616
}
1717
}))?
18-
.with_json_content(&serde_json::json!({
19-
"$schema": "http://json-schema.org/draft-07/schema#",
20-
"type": "object",
21-
"properties": {},
22-
"required": [],
23-
"additionalProperties": false
24-
}))?
25-
.build()?;
26-
Ok(doc)
18+
.with_json_content(&serde_json::json!({}))?
19+
.build()
2720
}

rust/signed_doc/tests/common/proposal_form_template.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub fn proposal_form_template_doc(
44
parameters_doc: &CatalystSignedDocument
55
) -> anyhow::Result<CatalystSignedDocument> {
66
let id = UuidV7::new();
7-
let doc = Builder::new()
7+
Builder::new()
88
.with_json_metadata(serde_json::json!({
99
"content-type": ContentType::Json.to_string(),
1010
"content-encoding": ContentEncoding::Brotli.to_string(),
@@ -17,6 +17,5 @@ pub fn proposal_form_template_doc(
1717
},
1818
}))?
1919
.with_json_content(&serde_json::json!({}))?
20-
.build()?;
21-
Ok(doc)
20+
.build()
2221
}

rust/signed_doc/tests/common/proposal_submission_action.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn proposal_submission_action_doc(
1111
let id = UuidV7::new();
1212
let (sk, _, kid) = create_dummy_key_pair(RoleId::Proposer)
1313
.inspect(|(_, pk, kid)| provider.add_pk(kid.clone(), pk.clone()))?;
14-
Ok(Builder::new()
14+
Builder::new()
1515
.with_json_metadata(serde_json::json!({
1616
"content-type": ContentType::Json.to_string(),
1717
"content-encoding": ContentEncoding::Brotli.to_string(),
@@ -31,5 +31,5 @@ pub fn proposal_submission_action_doc(
3131
"action": "final"
3232
}))?
3333
.add_signature(|m| sk.sign(&m).to_vec(), kid)?
34-
.build()?)
34+
.build()
3535
}

0 commit comments

Comments
 (0)