Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lightning/src/offers/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,13 @@ mod tests {
panic!("error parsing offer: {:?}", e);
}

let mut builder = OfferBuilder::new(pubkey(42));
builder.offer.paths = Some(vec![]);
Copy link
Collaborator

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.

Copy link
Contributor Author

@erickcestari erickcestari Aug 19, 2025

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
	}

Copy link
Collaborator

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.

let offer = builder.build().unwrap();
if let Err(e) = offer.to_string().parse::<Offer>() {
panic!("error parsing offer: {:?}", e);
}

let mut builder = OfferBuilder::new(pubkey(42));
builder.offer.issuer_signing_pubkey = None;
builder.offer.paths = Some(vec![]);
Expand Down
Loading