Skip to content

fuzz-tests: Add fuzz target for closing_sig #8244

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 2 commits into
base: master
Choose a base branch
from

Conversation

Chand-ra
Copy link

@Chand-ra Chand-ra commented Apr 22, 2025

closing_signed and closing_sig are channel closing negotiation messages defined in BOLT #2.

While closing_signed has a wire fuzz test, closing_sig does not. Add a test to perform a round-trip encoding check (towire -> fromwire) similar to the other wire fuzzers.

With this PR and #8216 , wire fuzzing is covered for all types of wire messages (except subtypes).

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.

CC: @morehouse

Comment on lines 35 to 37
assert(!memcmp(&x->channel_id, &y->channel_id, sizeof(struct channel_id)));
assert(x->locktime == y->locktime);
assert(!memcmp(&x->fee_satoshis, &y->fee_satoshis, sizeof(struct amount_sat)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert(!memcmp(&x->channel_id, &y->channel_id, sizeof(struct channel_id)));
assert(x->locktime == y->locktime);
assert(!memcmp(&x->fee_satoshis, &y->fee_satoshis, sizeof(struct amount_sat)));
assert(memcmp(&x->channel_id, &y->channel_id, sizeof(x->channel_id)) == 0);
assert(x->locktime == y->locktime);
assert(memcmp(&x->fee_satoshis, &y->fee_satoshis, sizeof(x->fee_satoshis)) == 0);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, my bad. This change should have been carried over from the review on #8216 .

assert(tal_arr_eq(x->closee_scriptpubkey, y->closee_scriptpubkey));

assert(x->tlvs && y->tlvs);
return tal_arr_eq(x->tlvs->closer_and_closee_outputs, y->tlvs->closer_and_closee_outputs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to compare these TLVs:

closer_output_only
closee_output_only

Chandra Pratap added 2 commits April 23, 2025 15:00
Changelog-None: 'closing_signed' and 'closing_sig' are
channel closing negotiation messages defined in BOLT ElementsProject#2.

While 'closing_signed' has a wire fuzz test, 'closing_sig'
does not. Add a test to perform a round-trip encoding check
(towire -> fromwire) similar to the other wire fuzzers.
Add a minimal input set as a seed corpus for the newly introduced
test. This leads to discovery of interesting code paths faster.
Copy link
Contributor

@morehouse morehouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 149cdfe

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