Skip to content

Commit

Permalink
tests back in
Browse files Browse the repository at this point in the history
Signed-off-by: George Mulhearn <[email protected]>
  • Loading branch information
gmulhearn-anonyome committed Oct 18, 2023
1 parent 8ae01b4 commit c5c4293
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 210 deletions.
6 changes: 3 additions & 3 deletions messages/src/msg_fields/protocols/present_proof/v2/ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod tests {
decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing},
misc::test_utils,
msg_fields::protocols::notification::ack::AckStatus,
msg_types::present_proof::PresentProofTypeV1_0,
msg_types::present_proof::PresentProofTypeV2_0,
};

#[test]
Expand All @@ -57,7 +57,7 @@ mod tests {
"~thread": decorators.thread
});

test_utils::test_msg(content, decorators, PresentProofTypeV1_0::Ack, expected);
test_utils::test_msg(content, decorators, PresentProofTypeV2_0::Ack, expected);
}

#[test]
Expand All @@ -75,6 +75,6 @@ mod tests {
"~timing": decorators.timing
});

test_utils::test_msg(content, decorators, PresentProofTypeV1_0::Ack, expected);
test_utils::test_msg(content, decorators, PresentProofTypeV2_0::Ack, expected);
}
}
139 changes: 78 additions & 61 deletions messages/src/msg_fields/protocols/present_proof/v2/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct PresentationV2Content {
pub goal_code: Option<String>,
pub formats: Vec<AttachmentFormatSpecifier<PresentationAttachmentFormatType>>,
#[serde(rename = "presentations~attach")]
pub requests_attach: Vec<Attachment>,
pub presentations_attach: Vec<Attachment>,
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)]
Expand All @@ -50,72 +50,89 @@ pub enum PresentationAttachmentFormatType {
DifPresentationExchangeSubmission1_0,
}

// #[cfg(test)]
// #[allow(clippy::unwrap_used)]
// #[allow(clippy::field_reassign_with_default)]
// mod tests {
// use serde_json::json;
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::field_reassign_with_default)]
mod tests {
use serde_json::json;
use shared_vcx::maybe_known::MaybeKnown;

// use super::*;
// use crate::{
// decorators::{
// attachment::tests::make_extended_attachment,
// please_ack::tests::make_minimal_please_ack, thread::tests::make_extended_thread,
// timing::tests::make_extended_timing,
// },
// misc::test_utils,
// msg_types::present_proof::PresentProofTypeV1_0,
// };
use super::*;
use crate::{
decorators::{
attachment::tests::make_extended_attachment,
please_ack::tests::make_minimal_please_ack, thread::tests::make_extended_thread,
timing::tests::make_extended_timing,
},
misc::test_utils,
msg_types::present_proof::PresentProofTypeV2_0,
};

// #[test]
// fn test_minimal_present_proof() {
// let content = PresentationV2Content::builder()
// .presentations_attach(vec![make_extended_attachment()])
// .build();
#[test]
fn test_minimal_present_proof() {
let content = PresentationV2Content::builder()
.formats(vec![AttachmentFormatSpecifier {
attach_id: "1".to_owned(),
format: MaybeKnown::Known(
PresentationAttachmentFormatType::HyperledgerIndyProof2_0,
),
}])
.presentations_attach(vec![make_extended_attachment()])
.build();

// let decorators = PresentationV2Decorators::builder()
// .thread(make_extended_thread())
// .build();
let decorators = PresentationV2Decorators::builder()
.thread(make_extended_thread())
.build();

// let expected = json!({
// "presentations~attach": content.presentations_attach,
// "~thread": decorators.thread
// });
let expected = json!({
"formats": content.formats,
"presentations~attach": content.presentations_attach,
"~thread": decorators.thread
});

// test_utils::test_msg(
// content,
// decorators,
// PresentProofTypeV1_0::Presentation,
// expected,
// );
// }
test_utils::test_msg(
content,
decorators,
PresentProofTypeV2_0::Presentation,
expected,
);
}

// #[test]
// fn test_extended_present_proof() {
// let content = PresentationV2Content::builder()
// .presentations_attach(vec![make_extended_attachment()])
// .comment("test_comment".to_owned())
// .build();
#[test]
fn test_extended_present_proof() {
let content = PresentationV2Content::builder()
.formats(vec![AttachmentFormatSpecifier {
attach_id: "1".to_owned(),
format: MaybeKnown::Known(
PresentationAttachmentFormatType::HyperledgerIndyProof2_0,
),
}])
.presentations_attach(vec![make_extended_attachment()])
.comment(Some("test_comment".to_owned()))
.goal_code(Some("goal.goal".to_owned()))
.build();

// let decorators = PresentationV2Decorators::builder()
// .thread(make_extended_thread())
// .timing(make_extended_timing())
// .please_ack(make_minimal_please_ack())
// .build();
let decorators = PresentationV2Decorators::builder()
.thread(make_extended_thread())
.timing(make_extended_timing())
.please_ack(make_minimal_please_ack())
.build();

// let expected = json!({
// "comment": content.comment,
// "presentations~attach": content.presentations_attach,
// "~thread": decorators.thread,
// "~timing": decorators.timing,
// "~please_ack": decorators.please_ack
// });
let expected = json!({
"comment": content.comment,
"goal_code": content.goal_code,
"formats": content.formats,
"presentations~attach": content.presentations_attach,
"~thread": decorators.thread,
"~timing": decorators.timing,
"~please_ack": decorators.please_ack
});

// test_utils::test_msg(
// content,
// decorators,
// PresentProofTypeV1_0::Presentation,
// expected,
// );
// }
// }
test_utils::test_msg(
content,
decorators,
PresentProofTypeV2_0::Presentation,
expected,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod tests {
msg_fields::protocols::report_problem::{
Description, Impact, Where, WhereParty, WhoRetries,
},
msg_types::present_proof::PresentProofTypeV1_0,
msg_types::present_proof::PresentProofTypeV2_0,
};

#[test]
Expand All @@ -75,7 +75,7 @@ mod tests {
test_utils::test_msg(
content,
decorators,
PresentProofTypeV1_0::ProblemReport,
PresentProofTypeV2_0::ProblemReport,
expected,
);
}
Expand Down Expand Up @@ -130,7 +130,7 @@ mod tests {
test_utils::test_msg(
content,
decorators,
PresentProofTypeV1_0::ProblemReport,
PresentProofTypeV2_0::ProblemReport,
expected,
);
}
Expand Down
138 changes: 70 additions & 68 deletions messages/src/msg_fields/protocols/present_proof/v2/propose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,80 +48,82 @@ pub enum ProposePresentationAttachmentFormatType {
HyperledgerIndyProofRequest2_0,
}

// #[cfg(test)]
// #[allow(clippy::unwrap_used)]
// #[allow(clippy::field_reassign_with_default)]
// mod tests {
// use serde_json::json;
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::field_reassign_with_default)]
mod tests {
use serde_json::json;
use shared_vcx::maybe_known::MaybeKnown;

// use super::*;
// use crate::{
// decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing},
// misc::test_utils,
// };
use super::*;
use crate::{
decorators::{
attachment::tests::make_extended_attachment, thread::tests::make_extended_thread,
timing::tests::make_extended_timing,
},
misc::test_utils,
msg_types::present_proof::PresentProofTypeV2_0,
};

// #[test]
// fn test_minimal_propose_proof() {
// let attribute = PresentationAttr::builder()
// .name("test_attribute_name".to_owned())
// .build();
// let predicate = Predicate::builder()
// .name("test_predicate_name".to_owned())
// .predicate(PredicateOperator::GreaterOrEqual)
// .threshold(1000)
// .build();
// let preview = PresentationPreview::new(vec![attribute], vec![predicate]);
// let content = ProposePresentationV2Content::builder()
// .presentation_proposal(preview)
// .build();
#[test]
fn test_minimal_propose_proof() {
let content = ProposePresentationV2Content::builder()
.formats(vec![OptionalIdAttachmentFormatSpecifier {
attach_id: None,
format: MaybeKnown::Known(
ProposePresentationAttachmentFormatType::HyperledgerIndyProofRequest2_0,
),
}])
.proposals_attach(None)
.build();

// let decorators = ProposePresentationV2Decorators::default();
let decorators = ProposePresentationV2Decorators::default();

// let expected = json!({
// "presentation_proposal": content.presentation_proposal
// });
let expected = json!({
"formats": content.formats
});

// test_utils::test_msg(
// content,
// decorators,
// PresentProofTypeV1_0::ProposePresentation,
// expected,
// );
// }
test_utils::test_msg(
content,
decorators,
PresentProofTypeV2_0::ProposePresentation,
expected,
);
}

// #[test]
// fn test_extended_propose_proof() {
// let attribute = PresentationAttr::builder()
// .name("test_attribute_name".to_owned())
// .build();
// let predicate = Predicate::builder()
// .name("test_predicate_name".to_owned())
// .predicate(PredicateOperator::GreaterOrEqual)
// .threshold(1000)
// .build();
// let preview = PresentationPreview::new(vec![attribute], vec![predicate]);
// let content = ProposePresentationV2Content::builder()
// .presentation_proposal(preview)
// .comment("test_comment".to_owned())
// .build();
#[test]
fn test_extended_propose_proof() {
let content = ProposePresentationV2Content::builder()
.formats(vec![OptionalIdAttachmentFormatSpecifier {
attach_id: Some("1".to_owned()),
format: MaybeKnown::Known(
ProposePresentationAttachmentFormatType::HyperledgerIndyProofRequest2_0,
),
}])
.proposals_attach(Some(vec![make_extended_attachment()]))
.goal_code(Some("goal.goal".to_owned()))
.comment(Some("test_comment".to_owned()))
.build();

// let decorators = ProposePresentationV2Decorators::builder()
// .thread(make_extended_thread())
// .timing(make_extended_timing())
// .build();
let decorators = ProposePresentationV2Decorators::builder()
.thread(Some(make_extended_thread()))
.timing(Some(make_extended_timing()))
.build();

// let expected = json!({
// "comment": content.comment,
// "presentation_proposal": content.presentation_proposal,
// "~thread": decorators.thread,
// "~timing": decorators.timing
// });
let expected = json!({
"comment": content.comment,
"goal_code": content.goal_code,
"formats": content.formats,
"proposals~attach": content.proposals_attach,
"~thread": decorators.thread,
"~timing": decorators.timing
});

// test_utils::test_msg(
// content,
// decorators,
// PresentProofTypeV1_0::ProposePresentation,
// expected,
// );
// }
// }
test_utils::test_msg(
content,
decorators,
PresentProofTypeV2_0::ProposePresentation,
expected,
);
}
}
Loading

0 comments on commit c5c4293

Please sign in to comment.