Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erickcestari
Copy link
Contributor

@erickcestari erickcestari commented Aug 18, 2025

Verifies that offers with empty paths are accepted as long as the issuer_id is set.

Follow-up: #4018

Verifies that offers with empty paths are accepted as long as the
issuer_id is set.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Aug 18, 2025

👋 I see @joostjager was un-assigned.
If you'd like another reviewer assignment, please click here.

Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.84%. Comparing base (5314ebb) to head (35a1693).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/offers/offer.rs 66.66% 1 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
fuzzing 21.76% <ø> (ø)
tests 88.68% <66.66%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt TheBlueMatt requested review from TheBlueMatt and removed request for joostjager August 19, 2025 15:43
@@ -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.

@ldk-reviews-bot
Copy link

👋 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants