Skip to content

smite: drive commitment tests from JSON vectors - #245

Merged
morehouse merged 2 commits into
lnfuzz:masterfrom
NishantBansal2003:refactor-commitment-tests
Sep 28, 2026
Merged

morehouse merged 2 commits into
lnfuzz:masterfrom
NishantBansal2003:refactor-commitment-tests

Conversation

@NishantBansal2003

@NishantBansal2003 NishantBansal2003 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

The first commit moves all the tests in commitment.rs into a submodule, and the second migrates the commitment signature verification tests to JSON verification.

Pros:

  • Removes repetitive code and makes it easier to extend commitment tests with new channel types or HTLC support.
  • Makes it easier to generate oracles from LDK/Eclair and print them directly in this schema.

Cons:

  • If more than one test vector fails, we only see the first test failure instead of all of them: Fixed in 54fb5db

@erickcestari erickcestari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Comment thread smite/src/channel_tx/commitment/tests/harness.rs
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>

@morehouse morehouse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very nice

Comment on lines +147 to +154
// Acceptor signs opener's commitment.
if !channel_config.verify_counterparty_signature(
&commitment_state,
&opener_holder,
&vector.remote_signature,
) {
failures.push(format!("{}: remote signature does not verify", vector.name));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks like we could also compute the remote_signature and compare against vector.remote_signature here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added, and it flagged that the LDK oracle we used to add vector.remote_signature creates the signature in low r form, while we sign it normally. So I used the Eclair oracles from #181 (comment) with the appropriate oracle params to get these signatures, since Eclair does not use low r signatures

Each BOLT 3 vector was a hand-written test repeating the same channel
setup and the same three signature assertions. Move the vectors into
JSON files under test_vectors/, split by channel type (Appendix C
legacy, Appendix F anchors, plus custom files for edge cases the
appendices miss), and run them through a shared harness. Adding a
vector is now a JSON entry, not a new test.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
@morehouse
morehouse merged commit 57f73e2 into lnfuzz:master Sep 28, 2026
5 checks passed
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