Skip to content

fuzz-tests: Add a test for calculate_our_funding() #8312

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Chand-ra
Copy link

@Chand-ra Chand-ra commented Jun 2, 2025

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

@Chand-ra
Copy link
Author

Chand-ra commented Jun 2, 2025

Hey @morehouse ,

this test fails with the error:

our_funds 0 < per_channel_min 18446744073709551615

but the function under test, plugins/funder_policy.c::calculate_our_funding(), has a check that's supposed to guard against this error:

if (amount_sat_less(*our_funding, policy->per_channel_min)) {
	*our_funding = AMOUNT_SAT(0);
	return error;
...
...
...
}

What could be the cause? I tried inspecting the breakage using gdb but the values upon inspection seem to vary from the error output. I've added the breaking input as the corpus, I'd appreciate your thoughts on this.

@morehouse
Copy link
Contributor

When it fails, is our_funds always 0?

The check is skipped when the returned amount is 0.

/* Don't return an 'error' if we're already at 0 */
if (amount_sat_is_zero(*our_funding))
return NULL;

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.

2 participants