fuzz: wallet, add target for `CoinControl` #27902

pull Ayush170-Future wants to merge 1 commits into bitcoin:master from Ayush170-Future:fuzz-coverage-coincontrol changing 2 files +88 −0
  1. Ayush170-Future commented at 4:35 PM on June 16, 2023: contributor

    This PR adds fuzz coverage for wallet/coincontrol.

    Motivation: Issue #27272

    The idea is to create different/unique instances of COutPoint by placing it inside the CallOneOf function, which may or may not be consumed by all of the CoinControl file's methods.

    This is my first PR on Bitcoin Core, and I will try my best to address any reviews/changes ASAP. I'm also working on fuzz harness files for other files in the wallet and plan to open PR for them soon.

  2. DrahtBot commented at 4:35 PM on June 16, 2023: 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.

    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 Jun 16, 2023
  4. in src/wallet/test/fuzz/coincontrol.cpp:32 in 74be54abdb outdated
      27 | +    ArgsManager& args = *node.args;
      28 | +
      29 | +    // for GetBoolArg to return true sometimes
      30 | +    if (fuzzed_data_provider.ConsumeBool()) {
      31 | +        args.ForceSetArg("-avoidpartialspends", "1");
      32 | +    }
    


    maflcko commented at 4:56 PM on June 16, 2023:
         
            args.ForceSetArg("-avoidpartialspends", fuzzed_data_provider.ConsumeBool()?"1":"0");
        
    

    nit, to avoid relying on the default value at all


    Ayush170-Future commented at 6:12 PM on June 16, 2023:

    Done! Thank you (I'm a big fan of your work).

  5. brunoerg commented at 5:32 PM on June 16, 2023: contributor

    lf you remove the trailing whitespace in new lines, lint will be happy:

    diff --git a/src/wallet/test/fuzz/coincontrol.cpp b/src/wallet/test/fuzz/coincontrol.cpp
    @@ -0,0 +1,89 @@
    +    
    +FUZZ_TARGET_INIT(coincontrol, initialize_coincontrol) 
    +    
    +                // Condition to avoid the assertion in GetInputWeight
    
  6. DrahtBot added the label CI failed on Jun 16, 2023
  7. Ayush170-Future force-pushed on Jun 16, 2023
  8. Ayush170-Future commented at 6:21 PM on June 16, 2023: contributor

    Force pushed addressing @MarcoFalke and @brunoerg reviews.

    • clang-format the code to remove all the trailing white spaces.
    • Avoided relying on the default values, by addressing changes in this review.
  9. DrahtBot removed the label CI failed on Jun 16, 2023
  10. in src/Makefile.test.include:199 in 241ca232dc outdated
     195 | @@ -196,6 +196,7 @@ endif
     196 |  FUZZ_WALLET_SRC = \
     197 |   wallet/test/fuzz/coinselection.cpp \
     198 |   wallet/test/fuzz/fees.cpp \
     199 | + wallet/test/fuzz/coincontrol.cpp \
    


    kevkevinpal commented at 8:51 PM on June 16, 2023:

    nit: move the path up to be organized alphabetically (feel free to ignore)


    Ayush170-Future commented at 9:44 AM on June 17, 2023:

    Yes, sure. Updating this.

  11. in src/wallet/test/fuzz/coincontrol.cpp:32 in 241ca232dc outdated
      27 | +    ArgsManager& args = *node.args;
      28 | +
      29 | +    // for GetBoolArg to return true sometimes
      30 | +    args.ForceSetArg("-avoidpartialspends", fuzzed_data_provider.ConsumeBool()?"1":"0");
      31 | +
      32 | +    CCoinControl coin_control;
    


    kevkevinpal commented at 9:07 PM on June 16, 2023:

    nit: are we not able to use coincontrol? does it conflict with line 23?


    Ayush170-Future commented at 9:50 AM on June 17, 2023:

    I don't think this will conflict, but I'll have to double-check. But I set it to coin_control to keep it consistent with the other places where CCoinControl is defined.

    Take a look at this: wallet/spend.cpp

  12. kevkevinpal approved
  13. kevkevinpal commented at 9:17 PM on June 16, 2023: contributor

    crACK 241ca232dcd0c38169423360de367caa9ee3f49b

    checked that we're covering all the functions in ./src/wallet/coincontrol.h and ./src/wallet/coincontrol.cpp

    have not yet run the fuzz tests on my local yet

  14. fuzz: wallet, add target for CoinControl 40b333e21f
  15. Ayush170-Future force-pushed on Jun 17, 2023
  16. Ayush170-Future commented at 6:30 PM on June 17, 2023: contributor

    Force pushed addressing @kevkevinpal review.

    • Changed the position of wallet/test/fuzz/coincontrol.cpp in the Makefile.test.include to organize it alphabetically.
  17. kevkevinpal commented at 9:21 PM on June 18, 2023: contributor

    reACK 40b333e

  18. Ayush170-Future requested review from maflcko on Jun 18, 2023
  19. fanquake requested review from dergoegge on Jun 19, 2023
  20. fanquake requested review from murchandamus on Jun 19, 2023
  21. maflcko commented at 8:47 AM on June 19, 2023: member

    lgtm ACK 40b333e21f8741e2f553df6b5dcff7277c00a982

  22. DrahtBot removed review request from maflcko on Jun 19, 2023
  23. brunoerg approved
  24. brunoerg commented at 1:15 PM on June 19, 2023: contributor

    crACK 40b333e21f8741e2f553df6b5dcff7277c00a982

  25. maflcko commented at 1:34 PM on June 19, 2023: member

    Did the author or someone else run this with the ubsan+integer sanitizer to check for any issues before merge?

  26. dergoegge approved
  27. dergoegge commented at 2:55 PM on June 19, 2023: member

    ACK 40b333e21f8741e2f553df6b5dcff7277c00a982

    Did the author or someone else run this with the ubsan+integer sanitizer to check for any issues before merge?

    Yes I did for ~15min on 64 cores. Should be enough given that there isn't much code under test (it plateaued pretty quickly).

  28. achow101 commented at 5:07 PM on June 19, 2023: member

    ACK 40b333e21f8741e2f553df6b5dcff7277c00a982

  29. achow101 merged this on Jun 19, 2023
  30. achow101 closed this on Jun 19, 2023

  31. sidhujag referenced this in commit d270bf7c2d on Jun 21, 2023
  32. bitcoin locked this on Jun 18, 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: 2026-04-21 18:13 UTC

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