From df5c98c1b5ee3106c26b73642cefb50b0cd61d38 Mon Sep 17 00:00:00 2001 From: oetyng Date: Sat, 19 Jun 2021 23:32:12 +0200 Subject: [PATCH] fix(tests): also match on the mapped errors The tests are setup to verify that a specific error is returned for a specific failure condition. With the associated type in the trait, we do not know the Error implementation type, and therefore map it into a catch-all "Signing" variant. To not break the tests, we extract the expected errors out of the enum variant when matching. --- src/dbc.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/dbc.rs b/src/dbc.rs index 52c4ea8..102556f 100644 --- a/src/dbc.rs +++ b/src/dbc.rs @@ -384,13 +384,6 @@ mod tests { dbc.transaction.inputs ); } - Err(Error::UnrecognisedAuthority) => { - assert!(n_wrong_signer_sigs.coerce::() > 0); - assert!(dbc - .transaction_sigs - .values() - .any(|(k, _)| verifier.verify_known_key(k).is_err())); - } Err(Error::DbcContentParentsDifferentFromTransactionInputs) => { assert!( n_add_random_parents.coerce::() > 0 || n_drop_parents.coerce::() > 0 @@ -407,6 +400,23 @@ mod tests { Err(Error::FailedSignature) => { assert_ne!(n_wrong_msg_sigs.coerce::(), 0); } + Err(Error::Signing(s)) if s == Error::FailedSignature.to_string() => { + assert_ne!(n_wrong_msg_sigs.coerce::(), 0); + } + Err(Error::UnrecognisedAuthority) => { + assert!(n_wrong_signer_sigs.coerce::() > 0); + assert!(dbc + .transaction_sigs + .values() + .any(|(k, _)| verifier.verify_known_key(k).is_err())); + } + Err(Error::Signing(s)) if s == Error::UnrecognisedAuthority.to_string() => { + assert!(n_wrong_signer_sigs.coerce::() > 0); + assert!(dbc + .transaction_sigs + .values() + .any(|(k, _)| verifier.verify_known_key(k).is_err())); + } res => panic!("Unexpected verification result {:?}", res), } }