test: enable self.chain = 'main' to work in python bitcoin test framework #21085

pull Saibato wants to merge 1 commits into bitcoin:master from Saibato:mainettests changing 2 files +10 −3
  1. Saibato commented at 10:17 AM on February 5, 2021: contributor

    mainchain and testchains could behave different. So make sure we can now easy test also mainnet behavior.

    Mainchain would fail until now because the key address pair where only for testnets and the rpc cookie was placed assuming testnets in an inaccessible subdir for mainchain,

  2. Allow self.chain = 'main' in python bitcoin test framework
    mainchain and testchains could behave different.
    So make sure we can now easy test this.
    cfa42905aa
  3. fanquake added the label Tests on Feb 5, 2021
  4. AKARAVENGER approved
  5. in test/functional/test_framework/util.py:404 in cfa42905aa
     398 | @@ -399,7 +399,10 @@ def get_auth_cookie(datadir, chain):
     399 |                      assert password is None  # Ensure that there is only one rpcpassword line
     400 |                      password = line.split("=")[1].strip("\n")
     401 |      try:
     402 | -        with open(os.path.join(datadir, chain, ".cookie"), 'r', encoding="ascii") as f:
     403 | +        subdir = chain
     404 | +        if subdir == "main":
     405 | +            subdir = ""
    


    luke-jr commented at 1:36 AM on February 24, 2021:

    Might be better to use "."

  6. in test/functional/test_framework/util.py:422 in cfa42905aa
     415 | @@ -413,7 +416,10 @@ def get_auth_cookie(datadir, chain):
     416 |  
     417 |  # If a cookie file exists in the given datadir, delete it.
     418 |  def delete_cookie_file(datadir, chain):
     419 | -    if os.path.isfile(os.path.join(datadir, chain, ".cookie")):
     420 | +    subdir = chain
     421 | +    if chain == "main":
     422 | +        subdir = ""
     423 | +    if os.path.isfile(os.path.join(datadir, subdir, ".cookie")):
    


    luke-jr commented at 1:37 AM on February 24, 2021:

    Instead of duplicating this logic, perhaps a new function to get the cookie filepath is in order.

  7. in test/functional/test_framework/test_framework.py:406 in cfa42905aa
     402 | @@ -403,7 +403,8 @@ def init_wallet(self, i):
     403 |              n = self.nodes[i]
     404 |              if wallet_name is not None:
     405 |                  n.createwallet(wallet_name=wallet_name, descriptors=self.options.descriptors, load_on_startup=True)
     406 | -            n.importprivkey(privkey=n.get_deterministic_priv_key().key, label='coinbase')
     407 | +            if self.chain != "main":
    


    luke-jr commented at 1:38 AM on February 24, 2021:

    Why?


    Saibato commented at 10:49 AM on February 24, 2021:

    because all the key address pair we have now are only for testnets and will when the chain get initialized used but fail checks, so that the test would not even start, We can gen them on the fly if we need keys and addresses. For mainchain tests.?

  8. luke-jr changes_requested
  9. DrahtBot commented at 2:45 AM on November 28, 2021: contributor

    <!--cf906140f33d8803c4a75a2196329ecb-->

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

    <sub>Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".</sub>

  10. DrahtBot added the label Needs rebase on Nov 28, 2021
  11. DrahtBot commented at 8:37 AM on November 28, 2021: 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:

    • #23608 (test: fix feature_rbf.py --descriptors and add to test runner by theStack)

    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.

  12. maflcko commented at 11:44 AM on February 22, 2022: member

    Are you still working on this?

  13. fanquake added the label Up for grabs on Apr 26, 2022
  14. fanquake closed this on Apr 26, 2022

  15. bitcoin locked this on Apr 26, 2023
  16. maflcko removed the label Up for grabs on Dec 12, 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-21 18:14 UTC

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