Skip to content

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 .

Copy link
Contributor

Choose a reason for hiding this comment

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

We have various _eq functions for clarity. In this case, channel_id_eq() and amount_sat_eq().

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

@rustyrussell rustyrussell merged commit c7052b7 into ElementsProject:master Sep 15, 2025
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