Skip to content

Commit 2b72684

Browse files
committed
Update some test assertions to compare the invariant vs display string
1 parent 7c9e7ee commit 2b72684

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

payjoin/src/send/mod.rs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -659,14 +659,13 @@ mod test {
659659
let proposed_version = Version::non_standard(88);
660660
proposal.unsigned_tx.version = proposed_version;
661661

662-
assert_eq!(
663-
ctx.process_proposal(proposal).unwrap_err().to_string(),
664-
InternalProposalError::VersionsDontMatch {
665-
proposed: proposed_version,
666-
original: original_version
667-
}
668-
.to_string()
669-
);
662+
assert!(matches!(
663+
ctx.process_proposal(proposal),
664+
Err(InternalProposalError::VersionsDontMatch {
665+
proposed,
666+
original
667+
}) if proposed == proposed_version && original == original_version
668+
));
670669
Ok(())
671670
}
672671

@@ -681,14 +680,13 @@ mod test {
681680
);
682681
proposal.unsigned_tx.lock_time = proposed_locktime;
683682

684-
assert_eq!(
685-
ctx.process_proposal(proposal).unwrap_err().to_string(),
686-
InternalProposalError::LockTimesDontMatch {
687-
proposed: proposed_locktime,
688-
original: original_locktime
689-
}
690-
.to_string()
691-
);
683+
assert!(matches!(
684+
ctx.process_proposal(proposal),
685+
Err(InternalProposalError::LockTimesDontMatch {
686+
proposed,
687+
original
688+
}) if proposed == proposed_locktime && original == original_locktime
689+
));
692690
Ok(())
693691
}
694692

@@ -741,17 +739,17 @@ mod test {
741739

742740
// Change the sequence number of the proposal
743741
let original_sequence = proposal.unsigned_tx.input.first().unwrap().sequence;
744-
let new_sequence = Sequence::from_consensus(original_sequence.to_consensus_u32() - 1);
745-
proposal.unsigned_tx.input.get_mut(0).unwrap().sequence = new_sequence;
746-
747-
assert_eq!(
748-
ctx.process_proposal(proposal).unwrap_err().to_string(),
749-
InternalProposalError::SenderTxinSequenceChanged {
750-
proposed: new_sequence,
751-
original: original_sequence
752-
}
753-
.to_string()
754-
);
742+
let proposed_sequence =
743+
Sequence::from_consensus(original_sequence.to_consensus_u32() - 1);
744+
proposal.unsigned_tx.input.get_mut(0).unwrap().sequence = proposed_sequence;
745+
746+
assert!(matches!(
747+
ctx.process_proposal(proposal),
748+
Err(InternalProposalError::SenderTxinSequenceChanged {
749+
proposed,
750+
original
751+
}) if proposed == proposed_sequence && original == original_sequence
752+
));
755753
Ok(())
756754
}
757755

0 commit comments

Comments
 (0)