test: check that `listdescriptors` descriptor strings are sorted #26156

pull theStack wants to merge 2 commits into bitcoin:master from theStack:202209-test-rpc-check_sorted_listdescriptors_strings changing 2 files +5 −1
  1. theStack commented at 5:46 PM on September 22, 2022: contributor

    This small PR adds a test for the change introduced in PR #25931 ("rpc: sort listdescriptors result", commit 50996241f2b0eefeaab4fcd11b9730fa2dc107ae). The correctness of the test can easily be verified by commenting out the std::sort call in the listdescriptors RPC implementation:

    diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
    index 09c74ea2da..3ed1a69b26 100644
    --- a/src/wallet/rpc/backup.cpp
    +++ b/src/wallet/rpc/backup.cpp
    @@ -1829,9 +1829,11 @@ RPCHelpMan listdescriptors()
             });
         }
    
    +    /*
         std::sort(wallet_descriptors.begin(), wallet_descriptors.end(), [](const auto& a, const auto& b) {
             return a.descriptor < b.descriptor;
         });
    +    */
    
         UniValue descriptors(UniValue::VARR);
         for (const WalletDescInfo& info : wallet_descriptors) {
    
    

    leading to a fail of the functional test wallet_listdescriptors.py.

  2. test: check that `listdescriptors` descriptor strings are sorted
    Tests the change introduced in PR #25931 ("rpc: sort listdescriptors
    result", commit 50996241f2b0eefeaab4fcd11b9730fa2dc107ae).
    d99af861d0
  3. fanquake added the label Tests on Sep 22, 2022
  4. DrahtBot commented at 3:06 AM on September 23, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #25747 (rpc: add ability to export/import descriptor files in listdescriptors and importdescriptors by w0xlt)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. jarolrod commented at 7:10 AM on September 23, 2022: member

    Should the help for this rpc and the entry for this rpc in descriptors.md be updated to mention that it is sorted?

  6. theStack commented at 10:43 AM on September 23, 2022: contributor

    Should the help for this rpc and the entry for this rpc in descriptors.md be updated to mention that it is sorted?

    Good point. I think for descriptors.md this is too much of a detail to be mentioned (the file only gives a rough one-line description of what each RPC does), but for the RPC help it would make sense. Will take a look.

  7. doc, rpc: mention that `listdescriptors` result is sorted by string representation 810c3dc7ef
  8. theStack commented at 1:19 PM on September 26, 2022: contributor

    Added a commit that extends the listdescriptors RPC help (https://github.com/bitcoin/bitcoin/pull/26156/commits/810c3dc7efbfa07e81f161848010e886e04929ea) by mentioning that the result is sorted by descriptor string representation, as suggested by @jarolrod.

  9. jarolrod approved
  10. jarolrod commented at 5:36 AM on September 27, 2022: member

    ACK 810c3dc7efbfa07e81f161848010e886e04929ea

  11. aureleoules approved
  12. aureleoules commented at 7:31 AM on September 27, 2022: member

    ACK 810c3dc7efbfa07e81f161848010e886e04929ea

  13. MarcoFalke merged this on Sep 27, 2022
  14. MarcoFalke closed this on Sep 27, 2022

  15. theStack deleted the branch on Sep 27, 2022
  16. sidhujag referenced this in commit 9bebfdb7fd on Sep 27, 2022
  17. bitcoin locked this on Sep 27, 2023

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-13 15:13 UTC

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