-
Notifications
You must be signed in to change notification settings - Fork 943
fuzz-tests: verify round‑trip scriptpubkey-to-addr conversion #8297
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
base: master
Are you sure you want to change the base?
Conversation
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the scope of this variable should be reduced to the if-block below.
tests/fuzz/fuzz-addr.c
Outdated
decode_scriptpubkey_from_addr(tmpctx, chainparams, addr, &decoded_script_pubkey); | ||
assert(tal_arr_eq(script_pubkey, decoded_script_pubkey)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check the returned bool as well:
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)); |
Code almost LGTM. Tested and verified coverage. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2d9ecbf
Currently,
fuzz-addr
only 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