Skip to content

Commit 28adeb9

Browse files
committed
fix tests and spelling
1 parent 7133d35 commit 28adeb9

File tree

4 files changed

+47
-34
lines changed

4 files changed

+47
-34
lines changed

rust/signed_doc/src/validator/rules/ver.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub(crate) struct VerRule;
1010
impl VerRule {
1111
/// Validates document `ver` field on the timestamps:
1212
/// 1. document `ver` cannot be smaller than document `id` field
13-
#[allow(clippy::unused_async)]
1413
pub(crate) async fn check<Provider>(
1514
&self,
1615
doc: &CatalystSignedDocument,
@@ -47,8 +46,8 @@ impl VerRule {
4746
}
4847

4948
if ver != id {
50-
let first_submited_doc = DocumentRef::new(id, id, DocLocator::default());
51-
if provider.try_get_doc(&first_submited_doc).await?.is_none() {
49+
let first_submitted_doc = DocumentRef::new(id, id, DocLocator::default());
50+
if provider.try_get_doc(&first_submitted_doc).await?.is_none() {
5251
doc.report().functional_validation(
5352
&format!("`ver` and `id` are not equal, ver: {ver}, id: {id}. Document with `id` and `ver` being equal MUST exist"),
5453
"Cannot get a first version document from the provider, document for which `id` and `ver` are equal.",
@@ -109,15 +108,15 @@ mod tests {
109108
.build()
110109
}
111110
=> true;
112-
"`ver` greater than `id` are equal"
111+
"`ver` greater than `id`"
113112
)]
114113
#[test_case(
115114
|provider| {
116115
let now = SystemTime::now()
117116
.duration_since(SystemTime::UNIX_EPOCH)
118117
.unwrap()
119118
.as_secs();
120-
let id = Uuid::new_v7(Timestamp::from_unix_time(now - 1, 0, 0, 0))
119+
let id = Uuid::new_v7(Timestamp::from_unix_time(now + 1, 0, 0, 0))
121120
.try_into()
122121
.unwrap();
123122
let first_doc = Builder::new()
@@ -135,7 +134,7 @@ mod tests {
135134
.build()
136135
}
137136
=> false;
138-
"`ver` less than `id` are equal"
137+
"`ver` less than `id`"
139138
)]
140139
#[test_case(
141140
|_| {

rust/signed_doc/tests/comment.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ async fn test_valid_comment_doc() {
126126

127127
// Create a main comment doc, contain all fields mention in the document (except
128128
// revocations and section)
129+
let id = UuidV7::new();
129130
let doc = Builder::new()
130131
.with_json_metadata(serde_json::json!({
131132
"content-type": ContentType::Json.to_string(),
132133
"content-encoding": ContentEncoding::Brotli.to_string(),
133134
"type": doc_types::PROPOSAL_COMMENT.clone(),
134-
"id": UuidV7::new(),
135-
"ver": UuidV7::new(),
135+
"id": id,
136+
"ver": id,
136137
"ref": {
137138
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
138139
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -180,13 +181,14 @@ async fn test_invalid_comment_doc_wrong_role() {
180181

181182
// Create a main comment doc, contain all fields mention in the document (except
182183
// revocations and section)
184+
let id = UuidV7::new();
183185
let doc = Builder::new()
184186
.with_json_metadata(serde_json::json!({
185187
"content-type": ContentType::Json.to_string(),
186188
"content-encoding": ContentEncoding::Brotli.to_string(),
187189
"type": doc_types::PROPOSAL_COMMENT.clone(),
188-
"id": UuidV7::new(),
189-
"ver": UuidV7::new(),
190+
"id": id,
191+
"ver": id,
190192
"ref": {
191193
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
192194
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -224,13 +226,14 @@ async fn test_invalid_comment_doc_wrong_role() {
224226

225227
#[tokio::test]
226228
async fn test_invalid_comment_doc_missing_parameters() {
229+
let id = UuidV7::new();
227230
let doc = Builder::new()
228231
.with_json_metadata(serde_json::json!({
229232
"content-type": ContentType::Json.to_string(),
230233
"content-encoding": ContentEncoding::Brotli.to_string(),
231234
"type": doc_types::PROPOSAL_COMMENT.clone(),
232-
"id": UuidV7::new(),
233-
"ver": UuidV7::new(),
235+
"id": id,
236+
"ver": id,
234237
"ref": {
235238
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
236239
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -266,13 +269,14 @@ async fn test_invalid_comment_doc_missing_parameters() {
266269

267270
#[tokio::test]
268271
async fn test_invalid_comment_doc_missing_template() {
272+
let id = UuidV7::new();
269273
let doc = Builder::new()
270274
.with_json_metadata(serde_json::json!({
271275
"content-type": ContentType::Json.to_string(),
272276
"content-encoding": ContentEncoding::Brotli.to_string(),
273277
"type": doc_types::PROPOSAL_COMMENT.clone(),
274-
"id": UuidV7::new(),
275-
"ver": UuidV7::new(),
278+
"id": id,
279+
"ver": id,
276280
"ref": {
277281
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
278282
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -308,13 +312,14 @@ async fn test_invalid_comment_doc_missing_template() {
308312

309313
#[tokio::test]
310314
async fn test_invalid_comment_doc_missing_ref() {
315+
let id = UuidV7::new();
311316
let doc = Builder::new()
312317
.with_json_metadata(serde_json::json!({
313318
"content-type": ContentType::Json.to_string(),
314319
"content-encoding": ContentEncoding::Brotli.to_string(),
315320
"type": doc_types::PROPOSAL_COMMENT.clone(),
316-
"id": UuidV7::new(),
317-
"ver": UuidV7::new(),
321+
"id": id,
322+
"ver": id,
318323
// "ref": {
319324
// "id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
320325
// "ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),

rust/signed_doc/tests/proposal.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ async fn test_valid_proposal_doc() {
7373

7474
// Create a main proposal doc, contain all fields mention in the document (except
7575
// collaborations and revocations)
76+
let id = UuidV7::new();
7677
let doc = Builder::new()
7778
.with_json_metadata(serde_json::json!({
7879
"content-type": ContentType::Json.to_string(),
7980
"content-encoding": ContentEncoding::Brotli.to_string(),
8081
"type": doc_types::PROPOSAL.clone(),
81-
"id": UuidV7::new(),
82-
"ver": UuidV7::new(),
82+
"id": id,
83+
"ver": id,
8384
"template": {
8485
"id": PROPOSAL_TEMPLATE_DOC.doc_id().unwrap(),
8586
"ver": PROPOSAL_TEMPLATE_DOC.doc_ver().unwrap(),
@@ -118,13 +119,14 @@ async fn test_invalid_proposal_doc_wrong_role() {
118119

119120
// Create a main proposal doc, contain all fields mention in the document (except
120121
// collaborations and revocations)
122+
let id = UuidV7::new();
121123
let doc = Builder::new()
122124
.with_json_metadata(serde_json::json!({
123125
"content-type": ContentType::Json.to_string(),
124126
"content-encoding": ContentEncoding::Brotli.to_string(),
125127
"type": doc_types::PROPOSAL.clone(),
126-
"id": UuidV7::new(),
127-
"ver": UuidV7::new(),
128+
"id": id,
129+
"ver": id,
128130
"template": {
129131
"id": PROPOSAL_TEMPLATE_DOC.doc_id().unwrap(),
130132
"ver": PROPOSAL_TEMPLATE_DOC.doc_ver().unwrap(),
@@ -153,13 +155,14 @@ async fn test_invalid_proposal_doc_wrong_role() {
153155

154156
#[tokio::test]
155157
async fn test_invalid_proposal_doc_missing_template() {
158+
let id = UuidV7::new();
156159
let doc = Builder::new()
157160
.with_json_metadata(serde_json::json!({
158161
"content-type": ContentType::Json.to_string(),
159162
"content-encoding": ContentEncoding::Brotli.to_string(),
160163
"type": doc_types::PROPOSAL.clone(),
161-
"id": UuidV7::new(),
162-
"ver": UuidV7::new(),
164+
"id": id,
165+
"ver": id,
163166
// "template": {
164167
// "id": PROPOSAL_TEMPLATE_DOC.doc_id().unwrap(),
165168
// "ver": PROPOSAL_TEMPLATE_DOC.doc_ver().unwrap(),
@@ -186,13 +189,14 @@ async fn test_invalid_proposal_doc_missing_template() {
186189

187190
#[tokio::test]
188191
async fn test_invalid_proposal_doc_missing_parameters() {
192+
let id = UuidV7::new();
189193
let doc = Builder::new()
190194
.with_json_metadata(serde_json::json!({
191195
"content-type": ContentType::Json.to_string(),
192196
"content-encoding": ContentEncoding::Brotli.to_string(),
193197
"type": doc_types::PROPOSAL.clone(),
194-
"id": UuidV7::new(),
195-
"ver": UuidV7::new(),
198+
"id": id,
199+
"ver": id,
196200
"template": {
197201
"id": PROPOSAL_TEMPLATE_DOC.doc_id().unwrap(),
198202
"ver": PROPOSAL_TEMPLATE_DOC.doc_ver().unwrap(),

rust/signed_doc/tests/submission.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ async fn test_valid_submission_action() {
6565
key_provider.add_pk(kid.clone(), pk);
6666

6767
// Create a main proposal submission doc, contain all fields mention in the document
68+
let id = UuidV7::new();
6869
let doc = Builder::new()
6970
.with_json_metadata(serde_json::json!({
7071
"content-type": ContentType::Json.to_string(),
7172
"content-encoding": ContentEncoding::Brotli.to_string(),
7273
"type": doc_types::PROPOSAL_SUBMISSION_ACTION.clone(),
73-
"id": UuidV7::new(),
74-
"ver": UuidV7::new(),
74+
"id": id,
75+
"ver": id,
7576
"ref": {
7677
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
7778
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -111,13 +112,14 @@ async fn test_invalid_submission_action_wrong_role() {
111112
let (sk, _pk, kid) = create_dummy_key_pair(RoleId::Role0).unwrap();
112113

113114
// Create a main proposal submission doc, contain all fields mention in the document
115+
let id = UuidV7::new();
114116
let doc = Builder::new()
115117
.with_json_metadata(serde_json::json!({
116118
"content-type": ContentType::Json.to_string(),
117119
"content-encoding": ContentEncoding::Brotli.to_string(),
118120
"type": doc_types::PROPOSAL_SUBMISSION_ACTION.clone(),
119-
"id": UuidV7::new(),
120-
"ver": UuidV7::new(),
121+
"id": id,
122+
"ver": id,
121123
"ref": {
122124
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
123125
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -148,13 +150,14 @@ async fn test_invalid_submission_action_wrong_role() {
148150

149151
#[tokio::test]
150152
async fn test_invalid_submission_action_corrupted_json() {
153+
let id = UuidV7::new();
151154
let doc = Builder::new()
152155
.with_json_metadata(serde_json::json!({
153156
"content-type": ContentType::Json.to_string(),
154157
"content-encoding": ContentEncoding::Brotli.to_string(),
155158
"type": doc_types::PROPOSAL_SUBMISSION_ACTION.clone(),
156-
"id": UuidV7::new(),
157-
"ver": UuidV7::new(),
159+
"id": id,
160+
"ver": id,
158161
"ref": {
159162
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
160163
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -181,13 +184,14 @@ async fn test_invalid_submission_action_corrupted_json() {
181184

182185
#[tokio::test]
183186
async fn test_invalid_submission_action_missing_ref() {
187+
let id = UuidV7::new();
184188
let doc = Builder::new()
185189
.with_json_metadata(serde_json::json!({
186190
"content-type": ContentType::Json.to_string(),
187191
"content-encoding": ContentEncoding::Brotli.to_string(),
188192
"type": doc_types::PROPOSAL_SUBMISSION_ACTION.clone(),
189-
"id": UuidV7::new(),
190-
"ver": UuidV7::new(),
193+
"id": id,
194+
"ver": id,
191195
// "ref": {
192196
// "id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
193197
// "ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),
@@ -216,13 +220,14 @@ async fn test_invalid_submission_action_missing_ref() {
216220

217221
#[tokio::test]
218222
async fn test_invalid_submission_action_missing_parameters() {
223+
let id = UuidV7::new();
219224
let doc = Builder::new()
220225
.with_json_metadata(serde_json::json!({
221226
"content-type": ContentType::Json.to_string(),
222227
"content-encoding": ContentEncoding::Brotli.to_string(),
223228
"type": doc_types::PROPOSAL_SUBMISSION_ACTION.clone(),
224-
"id": UuidV7::new(),
225-
"ver": UuidV7::new(),
229+
"id": id,
230+
"ver": id,
226231
"ref": {
227232
"id": DUMMY_PROPOSAL_DOC.doc_id().unwrap(),
228233
"ver": DUMMY_PROPOSAL_DOC.doc_ver().unwrap(),

0 commit comments

Comments
 (0)