test: refactor: introduce `replace_in_config` helper #26956

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202301-test-introduce_replace_in_config_helper changing 4 files +19 −18
  1. theStack commented at 4:48 PM on January 23, 2023: contributor

    Currently two functional tests (p2p_permissions.py and wallet_crosschain.py) include quite similar code for substituting strings in a TestNode's bitcoind configuration file, so refactoring that out to a dedicated helper method seems to make sense (probably other tests could need that too in the future).

  2. DrahtBot commented at 4:48 PM on January 23, 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.

    Type Reviewers
    ACK kouloumos
    Stale ACK brunoerg

    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 Jan 23, 2023
  4. kouloumos commented at 5:02 PM on January 23, 2023: contributor
  5. theStack force-pushed on Jan 23, 2023
  6. theStack force-pushed on Jan 23, 2023
  7. theStack commented at 6:33 PM on January 23, 2023: contributor
  8. in test/functional/test_framework/util.py:295 in d14740f126 outdated
     291 | @@ -292,6 +292,22 @@ def sha256sum_file(filename):
     292 |      return h.digest()
     293 |  
     294 |  
     295 | +def replace_in_config(node, replacements):
    


    kouloumos commented at 7:13 PM on January 23, 2023:

    nit: Didn't notice at first, but this is under "# Utility functions", I think it should be under "# Node functions"


    maflcko commented at 1:44 PM on January 24, 2023:

    We should probably remove those comments, given that they are wrong anyway. (modinv is under "Block functions", which is wrong)


    maflcko commented at 4:30 PM on January 27, 2023:

    nit: Shouldn't node functions be put under test_node.py, anyway?


    theStack commented at 10:51 PM on January 28, 2023:

    nit: Shouldn't node functions be put under test_node.py, anyway?

    Good idea, done.

  9. kouloumos commented at 7:15 PM on January 23, 2023: contributor

    ACK d14740f126c3df6784675ec427a994f5f6224071

  10. in test/functional/test_framework/util.py:304 in d14740f126 outdated
     299 | +        [("old", "new"), ("foo", "bar"), ...]
     300 | +    """
     301 | +    with open(node.bitcoinconf, 'r', encoding='utf8') as conf:
     302 | +        conf_data = conf.read()
     303 | +    for replacement in replacements:
     304 | +        assert len(replacement) == 2
    


    brunoerg commented at 12:59 PM on January 24, 2023:

    nit:

            assert_equal(len(replacement), 2)
    

    theStack commented at 10:51 PM on January 28, 2023:

    Done.

  11. brunoerg approved
  12. brunoerg commented at 6:19 PM on January 26, 2023: contributor

    crACK d14740f126c3df6784675ec427a994f5f6224071

  13. theStack force-pushed on Jan 28, 2023
  14. test: refactor: introduce `replace_in_config` helper b530d9605d
  15. theStack force-pushed on Jan 28, 2023
  16. theStack commented at 10:54 PM on January 28, 2023: contributor

    Force-pushed with a version that introduces the helper now as TestNode method (as suggested by Marco) where it's a better fit than in the util module. Sorry for invalidating ACKs, re-review should be quite trivial.

  17. kouloumos commented at 7:01 AM on January 31, 2023: contributor

    ACK b530d9605db863fd8d0e45e73ff2eb9462d1ad4c It's indeed a better fit as a TestNode method.

  18. maflcko merged this on Jan 31, 2023
  19. maflcko closed this on Jan 31, 2023

  20. theStack deleted the branch on Jan 31, 2023
  21. sidhujag referenced this in commit 40f9023d9e on Jan 31, 2023
  22. bitcoin locked this on Jan 31, 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-14 21:13 UTC

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