test: add fuzz test for private broadcast #35129

pull vasild wants to merge 1 commits into bitcoin:master from vasild:private_broadcast_fuzz changing 3 files +178 −5
  1. vasild commented at 12:57 PM on April 21, 2026: contributor

    Add a fuzz test that exercises the public methods of the PrivateBroadcast class from src/private_broadcast.h and checks for correctness.

  2. test: add fuzz test for private broadcast
    Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
    d31c86f255
  3. DrahtBot added the label Tests on Apr 21, 2026
  4. DrahtBot commented at 12:57 PM on April 21, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. vasild commented at 1:02 PM on April 21, 2026: contributor

    The test was originally provided by @kevkevinpal in #29415 (comment)

    There is a complementary fuzz test in #35090 which exercises the peerman / connman call paths while this one here calls directly the PrivateBroadcast methods.

  6. in src/test/fuzz/private_broadcast.cpp:24 in d31c86f255
      19 | +
      20 | +FUZZ_TARGET(private_broadcast)
      21 | +{
      22 | +    SeedRandomStateForTest(SeedRand::ZEROS);
      23 | +    FuzzedDataProvider fdp(buffer.data(), buffer.size());
      24 | +    SetMockTime(ConsumeTime(fdp));
    


    maflcko commented at 1:17 PM on April 21, 2026:

    Please don't use the legacy SetMockTime, which modifies the global and leaks the value between test cases. Probably fine here, but for consistency, I'd avoid it and use NodeClockContext.

    Also, it seems odd to hold the value constant, this will limit the possible coverage?

  7. in src/test/fuzz/private_broadcast.cpp:46 in d31c86f255
      41 | +            return next_nodeid++;
      42 | +        }
      43 | +        return fdp.ConsumeIntegralInRange<NodeId>(0, next_nodeid - 1);
      44 | +    };
      45 | +
      46 | +    while (fdp.remaining_bytes() > 0) {
    


    maflcko commented at 1:19 PM on April 21, 2026:

    Please use the LIMITED_WHILE pattern with ConsumeBool(). Otherwise, if something is added later, it will be silently dead code. Of course, it is fine right now, but just taking the risk in the future seems not worth it.

  8. DrahtBot added the label CI failed on Apr 21, 2026
  9. DrahtBot commented at 1:45 PM on April 21, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task tidy: https://github.com/bitcoin/bitcoin/actions/runs/24723618894/job/72318638206</sub> <sub>LLM reason (✨ experimental): CI failed because clang-tidy reported a warnings-as-errors performance-unnecessary-copy-initialization in test/fuzz/private_broadcast.cpp (copy-constructing tx from a const reference).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  10. fanquake added the label Private Broadcast on Apr 21, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me