fuzz: add target for local address stuff #29495

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2024-02-fuzz-local changing 1 files +37 −0
  1. brunoerg commented at 7:41 pm on February 27, 2024: contributor
    This PR adds fuzz target for local address functions - (AddLocal, RemoveLocal, SeenLocal, IsLocal)
  2. DrahtBot commented at 7:41 pm on February 27, 2024: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK dergoegge, vasild

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Feb 27, 2024
  4. in src/test/fuzz/net.cpp:84 in 348a4c0ca8 outdated
    76@@ -77,3 +77,33 @@ FUZZ_TARGET(net, .init = initialize_net)
    77     (void)node.HasPermission(net_permission_flags);
    78     (void)node.ConnectedThroughNetwork();
    79 }
    80+
    81+FUZZ_TARGET(local_address, .init = initialize_net)
    82+{
    83+    FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
    84+    SetMockTime(ConsumeTime(fuzzed_data_provider));
    


    dergoegge commented at 11:05 pm on February 27, 2024:
    Is this really necessary?

    brunoerg commented at 10:46 am on February 28, 2024:
    Not necessary, just removed it.
  5. in src/test/fuzz/net.cpp:97 in 348a4c0ca8 outdated
    88+            fuzzed_data_provider,
    89+            [&] {
    90+                service = ConsumeService(fuzzed_data_provider);
    91+            },
    92+            [&] {
    93+                const bool added{AddLocal(service, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 5))};
    


    dergoegge commented at 11:07 pm on February 27, 2024:
    This harness will be non-deterministic and run out of memory since local addresses are stored in a global map. You’ll need to reset mapLocalHost each iteration.

    brunoerg commented at 10:46 am on February 28, 2024:
    Done.
  6. in src/test/fuzz/net.cpp:114 in 348a4c0ca8 outdated
    102+            [&] {
    103+                (void)SeenLocal(service);
    104+            },
    105+            [&] {
    106+                (void)IsLocal(service);
    107+            });
    


    dergoegge commented at 11:11 pm on February 27, 2024:
    How about adding coverage for GetLocal as well?
  7. dergoegge changes_requested
  8. brunoerg force-pushed on Feb 28, 2024
  9. brunoerg commented at 10:48 am on February 28, 2024: contributor

    Force-pushed addressing: #29495 (review) #29495 (review) #29495 (review)

    Thanks, @dergoegge

  10. in src/test/fuzz/net.cpp:112 in 36efe6bb55 outdated
    107+            },
    108+            [&] {
    109+                (void)IsLocal(service);
    110+            },
    111+            [&] {
    112+                auto peer{ConsumeNode(fuzzed_data_provider)};
    


    dergoegge commented at 5:36 pm on February 28, 2024:
    Probably better to not consume a whole CNode each time, maybe do what you did with the service.

    brunoerg commented at 6:32 pm on February 28, 2024:
    Even not being able to overload, sgtm to not consume each time, addressing it.
  11. brunoerg force-pushed on Feb 28, 2024
  12. brunoerg commented at 6:33 pm on February 28, 2024: contributor
    Force-pushed addressing #29495 (review)
  13. in src/test/fuzz/net.cpp:97 in fe4e38c257 outdated
    92+            fuzzed_data_provider,
    93+            [&] {
    94+                service = ConsumeService(fuzzed_data_provider);
    95+            },
    96+            [&] {
    97+                const bool added{AddLocal(service, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 5))};
    


    vasild commented at 1:06 pm on February 29, 2024:

    Maybe use LOCAL_MAX here instead of hardcoding 5:

    0                const bool added{AddLocal(service, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, LOCAL_MAX - 1))};
    

    brunoerg commented at 5:17 pm on February 29, 2024:
    Nice. Done.
  14. vasild approved
  15. vasild commented at 1:09 pm on February 29, 2024: contributor
    ACK fe4e38c25738356a227dc8e84b6a24d837ba8215
  16. fuzz: add target for local addresses 25eab52389
  17. brunoerg force-pushed on Feb 29, 2024
  18. brunoerg commented at 5:18 pm on February 29, 2024: contributor
    Force-pushed addressing #29495 (review). Thanks, @vasild.
  19. dergoegge approved
  20. dergoegge commented at 5:20 pm on February 29, 2024: member
    ACK 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc
  21. DrahtBot requested review from vasild on Feb 29, 2024
  22. vasild approved
  23. vasild commented at 7:29 am on March 1, 2024: contributor
    ACK 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc
  24. DrahtBot added the label Needs rebase on Mar 1, 2024
  25. DrahtBot commented at 3:14 pm on March 1, 2024: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

  26. fanquake commented at 3:15 pm on March 1, 2024: member
    This has been merged.
  27. fanquake closed this on Mar 1, 2024

  28. fanquake referenced this in commit ae4165f7bc on Mar 1, 2024

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: 2024-06-29 07:13 UTC

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