fuzz-tests: verify round‑trip scriptpubkey-to-addr conversion#8297
Merged
rustyrussell merged 2 commits intoElementsProject:masterfrom Sep 15, 2025
Merged
fuzz-tests: verify round‑trip scriptpubkey-to-addr conversion#8297rustyrussell merged 2 commits intoElementsProject:masterfrom
rustyrussell merged 2 commits intoElementsProject:masterfrom
Conversation
morehouse
reviewed
May 19, 2025
tests/fuzz/fuzz-addr.c
Outdated
| encode_scriptpubkey_to_addr(tmpctx, chainparams, script_pubkey); | ||
| char *addr = encode_scriptpubkey_to_addr(tmpctx, chainparams, script_pubkey); | ||
|
|
||
| uint8_t *decoded_script_pubkey; |
Contributor
There was a problem hiding this comment.
Nit: the scope of this variable should be reduced to the if-block below.
tests/fuzz/fuzz-addr.c
Outdated
Comment on lines
+24
to
+23
| decode_scriptpubkey_from_addr(tmpctx, chainparams, addr, &decoded_script_pubkey); | ||
| assert(tal_arr_eq(script_pubkey, decoded_script_pubkey)); |
Contributor
There was a problem hiding this comment.
We should check the returned bool as well:
Suggested change
| decode_scriptpubkey_from_addr(tmpctx, chainparams, addr, &decoded_script_pubkey); | |
| assert(tal_arr_eq(script_pubkey, decoded_script_pubkey)); | |
| assert(decode_scriptpubkey_from_addr(tmpctx, chainparams, addr, &decoded_script_pubkey)); | |
| assert(tal_arr_eq(script_pubkey, decoded_script_pubkey)); |
Contributor
|
Code almost LGTM. Tested and verified coverage. |
added 2 commits
May 20, 2025 08:32
Changelog-None: Currently, fuzz-addr only tests encoding via encode_scriptpubkey_to_addr(), without checking decoding. Add a round‑trip assertion: if encoding produces an address, decode it back with decode_scriptpubkey_from_addr() and confirm the result matches the original scriptpubkey.
Change in the fuzz-testing scheme of fuzz-addr led to the discovery of test inputs that result in greater in code coverage. Add these inputs to the test's seed corpus.
morehouse
approved these changes
May 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently,
fuzz-addronly tests encoding viaencode_scriptpubkey_to_addr(), without checking decoding. Add a round‑trip assertion: if encoding produces an address, decode it back withdecode_scriptpubkey_from_addr()and confirm the result matches the original scriptpubkey.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:
CC: @morehouse