-
Notifications
You must be signed in to change notification settings - Fork 419
test: add test for offer parsing with empty paths and valid issuer #4020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Verifies that offers with empty paths are accepted as long as the issuer_id is set.
👋 I see @joostjager was un-assigned. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4020 +/- ##
==========================================
- Coverage 88.86% 88.84% -0.02%
==========================================
Files 175 175
Lines 127725 127731 +6
Branches 127725 127731 +6
==========================================
- Hits 113501 113486 -15
- Misses 11662 11684 +22
+ Partials 2562 2561 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -2002,6 +2002,13 @@ mod tests { | |||
panic!("error parsing offer: {:?}", e); | |||
} | |||
|
|||
let mut builder = OfferBuilder::new(pubkey(42)); | |||
builder.offer.paths = Some(vec![]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just use builder.clear_paths()
? If you really want you could even check that the offer built in pays_for_offer_without_blinded_paths
round-trips.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ideia is to test this specifc scenario:
Where path is Some(empty_vector)
and with a valid issuer_id
since we moved from:
let (issuer_signing_pubkey, paths) = match (issuer_id, paths) {
(None, None) => return Err(Bolt12SemanticError::MissingIssuerSigningPubkey),
(_, Some(paths)) if paths.is_empty() => return Err(Bolt12SemanticError::MissingPaths),
(issuer_id, paths) => (issuer_id, paths),
};
to:
let (issuer_signing_pubkey, paths) = match (issuer_id, paths) {
(None, None) => return Err(Bolt12SemanticError::MissingIssuerSigningPubkey),
(None, Some(paths)) if paths.is_empty() => {
return Err(Bolt12SemanticError::MissingPaths)
},
(issuer_id, paths) => (issuer_id, paths),
};
so before the update this new test would fail.
builder.clear_paths()
would insert None
into offer.paths
which isn't the case we want to test
#[cfg_attr(c_bindings, allow(dead_code))]
pub(crate) fn clear_paths($($self_mut)* $self: $self_type) -> $return_type {
$self.offer.paths = None;
$return_value
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm, then we need to test actually paying such a blinded path, not just decoding it.
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
Verifies that offers with empty paths are accepted as long as the
issuer_id
is set.Follow-up: #4018