Skip to content

Commit f74aeb3

Browse files
Remove the 'rule' helper function from the tests
1 parent 667653b commit f74aeb3

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

rust/signed_doc/src/validator/rules/signature/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414

1515
/// Signed Document signatures validation rule.
1616
#[derive(Debug)]
17-
pub(crate) struct SignatureRule {}
17+
pub(crate) struct SignatureRule;
1818

1919
impl SignatureRule {
2020
/// Verify document signatures.

rust/signed_doc/src/validator/rules/signature/tests.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ fn metadata() -> serde_json::Value {
2727
})
2828
}
2929

30-
fn rule() -> SignatureRule {
31-
SignatureRule {}
32-
}
33-
3430
#[tokio::test]
3531
async fn single_signature_validation_test() {
3632
let (sk, pk, kid) = create_dummy_key_pair(RoleId::Role0);
@@ -51,13 +47,13 @@ async fn single_signature_validation_test() {
5147
let mut provider = TestCatalystProvider::default();
5248
provider.add_pk(kid.clone(), pk);
5349
assert!(
54-
rule().check(&signed_doc, &provider).await.unwrap(),
50+
SignatureRule.check(&signed_doc, &provider).await.unwrap(),
5551
"{:?}",
5652
signed_doc.problem_report()
5753
);
5854

5955
// case: empty provider
60-
assert!(!rule()
56+
assert!(!SignatureRule
6157
.check(&signed_doc, &TestCatalystProvider::default())
6258
.await
6359
.unwrap());
@@ -71,7 +67,7 @@ async fn single_signature_validation_test() {
7167
.unwrap()
7268
.build()
7369
.unwrap();
74-
assert!(!rule().check(&invalid_doc, &provider).await.unwrap());
70+
assert!(!SignatureRule.check(&invalid_doc, &provider).await.unwrap());
7571

7672
// case: missing signatures
7773
let unsigned_doc = Builder::new()
@@ -86,7 +82,7 @@ async fn single_signature_validation_test() {
8682
.unwrap()
8783
.build()
8884
.unwrap();
89-
assert!(!rule().check(&unsigned_doc, &provider).await.unwrap());
85+
assert!(!SignatureRule.check(&unsigned_doc, &provider).await.unwrap());
9086
}
9187

9288
#[tokio::test]
@@ -117,21 +113,21 @@ async fn multiple_signatures_validation_test() {
117113
provider.add_pk(kid1.clone(), pk1);
118114
provider.add_pk(kid2.clone(), pk2);
119115
provider.add_pk(kid3.clone(), pk3);
120-
assert!(rule().check(&signed_doc, &provider).await.unwrap());
116+
assert!(SignatureRule.check(&signed_doc, &provider).await.unwrap());
121117

122118
// case: partially available signatures
123119
let mut provider = TestCatalystProvider::default();
124120
provider.add_pk(kid1.clone(), pk1);
125121
provider.add_pk(kid2.clone(), pk2);
126-
assert!(!rule().check(&signed_doc, &provider).await.unwrap());
122+
assert!(!SignatureRule.check(&signed_doc, &provider).await.unwrap());
127123

128124
// case: with unrecognized provider
129125
let mut provider = TestCatalystProvider::default();
130126
provider.add_pk(kid_n.clone(), pk_n);
131-
assert!(!rule().check(&signed_doc, &provider).await.unwrap());
127+
assert!(!SignatureRule.check(&signed_doc, &provider).await.unwrap());
132128

133129
// case: no valid signatures available
134-
assert!(!rule()
130+
assert!(!SignatureRule
135131
.check(&signed_doc, &TestCatalystProvider::default())
136132
.await
137133
.unwrap());
@@ -281,7 +277,7 @@ async fn special_cbor_cases() {
281277
.unwrap();
282278

283279
assert!(
284-
rule().check(&doc, &provider).await.unwrap(),
280+
SignatureRule.check(&doc, &provider).await.unwrap(),
285281
"[case: {}] {:?}",
286282
case.name,
287283
doc.problem_report()

0 commit comments

Comments
 (0)