Add test for ArgsManager::GetChainName #15988

pull ryanofsky wants to merge 3 commits into bitcoin:master from ryanofsky:pr/testset2 changing 2 files +149 −42
  1. ryanofsky commented at 11:30 AM on May 9, 2019: member

    There was some test coverage previously, but it was limited and didn't test conflicting and negated arguments.

  2. util_SettingsMerge test cleanup
    Followup to #15869. Treat "-wallet" as the network-specific argument in test
    instead of "-server", to make test output clearer and be more consistent with
    bitcoind. Update embedded hash to match changed output from this.
    05bfee3451
  3. Add unit test NextString, ForEachNoDup functions
    Remove testcase generating code from util_SettingsMerge so it can be reused in
    new tests.
    
    The hash value expected in util_SettingsMerge changes as a result of this, but
    only because the testcases are generated in a different order, not because any
    cases are added or removed. It is possible to verify this with:
    
        SETTINGS_MERGE_TEST_OUT=new.txt test/test_bitcoin --run_test=util_tests/util_SettingsMerge
        git checkout HEAD~1
        make test/test_bitcoin
        SETTINGS_MERGE_TEST_OUT=old.txt test/test_bitcoin --run_test=util_tests/util_SettingsMerge
        diff -u <(sort old.txt) <(sort new.txt)
    
    The new output is a little more readable, with simpler testcases sorted first.
    4b331159df
  4. Add test for ArgsManager::GetChainName
    There was some test coverage previously, but it was limited and didn't test
    conflicting and negated arguments.
    f6bb11fd37
  5. fanquake added the label Tests on May 9, 2019
  6. in src/test/util_tests.cpp:814 in ede1812765 outdated
     811 | +        TestArgsManager parser;
     812 | +        LOCK(parser.cs_args);
     813 | +        parser.AddArg("-regtest", "regtest", false, OptionsCategory::OPTIONS);
     814 | +        parser.AddArg("-testnet", "testnet", false, OptionsCategory::OPTIONS);
     815 | +
     816 | +        auto arg = [](Action action) { return action == SET_TEST ? "-testnet" : action == NEGATE_TEST ? "-notestnet" : action == SET_REG ? "-regtest" : action == NEGATE_REG ? "-noregtest" : nullptr; };
    


    MarcoFalke commented at 11:42 AM on May 9, 2019:

    style-nit: Could flow into multiple lines?

  7. in src/test/util_tests.cpp:609 in ede1812765 outdated
     606 |      //! Max number of actions to sequence together. Can decrease this when
     607 |      //! debugging to make test results easier to understand.
     608 |      static constexpr int MAX_ACTIONS = 3;
     609 |  
     610 | -    enum Action { SET = 0, NEGATE, SECTION_SET, SECTION_NEGATE, END };
     611 | +    enum Action { END, SET, NEGATE, SECTION_SET, SECTION_NEGATE };
    


    MarcoFalke commented at 11:50 AM on May 9, 2019:

    In commit 00093ed7aae76d98792cfe9e3706ec3e27be2a13

    Shouldn't this be named (or similar)

        enum Action { NONE, SET, NEGATE, SECTION_SET, SECTION_NEGATE };
    
  8. MarcoFalke approved
  9. MarcoFalke commented at 11:54 AM on May 9, 2019: member

    ACK, just some style questions. Will scroll through the generated file later today.

  10. DrahtBot commented at 2:39 PM on May 9, 2019: member

    <!--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:

    • #15926 (tinyformat: Add format_no_throw by MarcoFalke)

    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.

  11. ryanofsky force-pushed on May 9, 2019
  12. ryanofsky commented at 3:15 PM on May 9, 2019: member

    Updated ede18127657652aa1b49b4370f53cb1bfb2e0886 -> 0a82350f92e087ba4dab276215679a1044c8bf2e (pr/testset2.1 -> pr/testset2.2, compare) with Marco's suggestions (thanks!)

  13. MarcoFalke commented at 4:24 PM on May 13, 2019: member

    utACK 0a82350f92e087ba4dab276215679a1044c8bf2e

    Checked that 4b331159dfa599eced9f9d4e5780173367b43c74 only re-sorts the txt file Checked that 0a82350f92e087ba4dab276215679a1044c8bf2e produces a nice file which looks plausibly correct (only checked the first 5 lines)

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    utACK 0a82350f92e087ba4dab276215679a1044c8bf2e
    
    Checked that 4b331159dfa599eced9f9d4e5780173367b43c74 only re-sorts the txt file
    Checked that 0a82350f92e087ba4dab276215679a1044c8bf2e produces a nice file which looks plausibly correct (only checked the first 5 lines)
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUgagAv7BrgDc1Dcsc7PdRJLiKhqhRZ0UAL5FbNROeLV232+YJHopWYdMJYhvPL7
    xvQkMgrLyDy/xvDR74+2CusA0pX+YaAICit9QSV4r+Vb6WwAuuXNB+g757JVvqJI
    ietTVrW2zK3sk8x7UWCPssJGUQruXnk3gQM2A7SMBgy8Xs4pPSWgv3CdfctGcyLL
    ncoW/wEgRRJgMWJml3NFbdTogD525IoCDpPlOAEAIUwlXTeNzKvC6m2erJ7UaNvt
    iof1t5gZOFiPR5s/Gd81BRjpjYuxnJ7xFRd0fUUcuVVmdxiosoEe3u0/xb9RCCRf
    PD9Ii+L1Ba8/TAYF8xZ/lxmH+8g+cN/SiJ2fcPM+dAi0wEbBXwYo3py5QYjUbjYO
    0G0j/yn95HFZOcyrgKDSaCClA2wXDbWVFdxTMGlzfMza5OG2ZKcxmclLelskiqtY
    sUBJGksj4RGgnPZHEJ/NfiSzUGOE7U9rUn5BTvrMxJaoSFJelNeRtrYcrdzwt6M/
    J8XA0Ror
    =TUSH
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 81dc0a6c7efde6beda8e20d7654843fbdeddec4c54e180c02d9c193b1a3225ef -

    </details>

  14. ryanofsky force-pushed on May 13, 2019
  15. ryanofsky commented at 4:34 PM on May 13, 2019: member

    Updated 0a82350f92e087ba4dab276215679a1044c8bf2e -> f6bb11fd37f8a2c985786b688ea07699ba75780e (pr/testset2.2 -> pr/testset2.3, compare) adding test for disabled arguments (-regtest=0) in addition to negated arguments (-noregtest)

  16. MarcoFalke commented at 4:40 PM on May 13, 2019: member

    I think we should still test for flags on the command line (I'd doubt that anyone types -regtest=1 over -regtest)

  17. ryanofsky commented at 5:37 PM on May 13, 2019: member

    I think we should still test for flags on the command line (I'd doubt that anyone types -regtest=1 over -regtest)

    I could add more variations to test this, but the reason I didn't is because InterpretBool(), interprets both"1" and the empty string as true, and we already have tests for variations of InterpretBool parsing behavior elsewhere.

    https://github.com/bitcoin/bitcoin/blob/e79bbb73e08e3f191e97d3b67a2fbb510c5545ff/src/util/system.cpp#L159-L164

    I think the new test will be less fragile if it is only testing merging of overlapping and negated settings and not trying to test boolean parsing at the same time.

    Another option would be to test -regtest instead of -regtest=1 not in addition to it. I didn't do this because it would make translating enum values into argument and config strings messier, but I could do it if you'd really prefer it.

  18. MarcoFalke commented at 7:12 PM on May 13, 2019: member

    re-utACK f6bb11fd37f8a2c985786b688ea07699ba75780e

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    re-utACK f6bb11fd37f8a2c985786b688ea07699ba75780e
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUhZeAv/esRJrFMEBsJ5m0DMtJYJEC8wlFodQn4/2qpURnfd84q3IjefgrFAoZ4N
    Iz1f5Q6mLN8HJNyHppbnsqgtO5DWFyH/EuXnKV0/G+qRTreltdGla8mxQ3YIveZ0
    hmaa/ReAz3/aCfTQtRqtbXId8cg1+ReemaEIfadtZYOvvEAsgThGM6WQBV6VW9Rb
    f1P1jIhkoX4c1VaqC5HLC73ZQk8La2kC/yrG9pHRTX056hpWlf1Yn20dyxwlrcoT
    84/JnntV7PXFaxxw0gakrKwUKnckGJwmg0oBMr8XeH01vzE/VXBVizQUFXiRZ8uC
    twZ4mAGpOdXtOLqUgTPJgLRQxQnFbnw4RwBaCBD+FtLm6PMJOAzoXxM+356Yk19n
    tAoUyuTBLZHvzQ4VICbMzS/KoS6r+UM7ObZpcITgyteV846GuvD0kNXZ+ablOyJQ
    BPBYf8Jr/C6bZ2zQrulyTQgiiO2APS5b891Z1saYMauwTOAuK2zqImTarKxgz96/
    2/7KVy4H
    =IS1+
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 9e787e94a78c234ae577714f7e54430e71958b3215367ff36ed61ff3a94b49ad -

    </details>

  19. MarcoFalke referenced this in commit 6f4ba6492a on May 14, 2019
  20. MarcoFalke merged this on May 14, 2019
  21. MarcoFalke closed this on May 14, 2019

  22. sidhujag referenced this in commit aae3cb93db on May 18, 2019
  23. laanwj referenced this in commit a7aec7ad97 on Nov 8, 2019
  24. sidhujag referenced this in commit 16a52029e7 on Nov 9, 2019
  25. deadalnix referenced this in commit b2500c3d81 on Apr 28, 2020
  26. sidhujag referenced this in commit c1677b430c on Nov 10, 2020
  27. DrahtBot locked this on Dec 16, 2021

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-25 00:14 UTC

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