tests: Add test for loadblock option and linearize scripts #17091

pull fjahr wants to merge 1 commits into bitcoin:master from fjahr:loadblock_test changing 3 files +89 −1
  1. fjahr commented at 10:52 pm on October 9, 2019: member

    Fixes #17019

    Was initially part of #17044 but as the test got larger it made sense to split it into its own commit as suggested in #17019 .

    This is testing the -loadblock option by using the scripts in contrib/linearize to generate a bootstrap.dat file and starting a disconnected node with it. So it is also testing the linearize scripts which were untested before and needed to be made available for the CI environment, hence they are added to DIST_CONTRIB in Makefile.am.

  2. fanquake added the label Tests on Oct 9, 2019
  3. laanwj commented at 9:16 am on October 10, 2019: member
    Concept ACK, thanks.
  4. in test/functional/feature_loadblock.py:62 in b94959e1a1 outdated
    56+        linearize_dir = os.path.join(base_dir, "contrib", "linearize")
    57+
    58+        self.log.info("Run linearization of block hashes")
    59+        linearize_hashes_path = os.path.join(linearize_dir, "linearize-hashes.py")
    60+        hashes_args = [linearize_hashes_path, cfg_path, ">", hashlist_path]
    61+        subprocess.run(" ".join(hashes_args), shell=True).check_returncode()
    


    laanwj commented at 9:18 am on October 10, 2019:
    Do you really need the shell=True here? The immediate problem is that the arguments aren’t escaped, so this won’t work with paths with spaces, or other characters in it. You could escape the args with shlex.quote, but in general, it’s better to avoid the shell completely and use Python’s stdin/stdout/stderr redirection.

    fjahr commented at 1:14 pm on October 10, 2019:
    I think there is no way around it since output redirect with > is a shell feature. I could not find a different way to achieve it. In a normal case I would have used Pythons output redirect but I wanted to simulate the use of the scripts exactly as described in the script’s README. I guess one way to get rid of it would be to extend linearize-hashes.py to take an output parameter like linearize-data.py does. I could do this here or in a follow-up PR.

    fjahr commented at 1:15 pm on October 10, 2019:
    I added quote for now to make it more robust.

    MarcoFalke commented at 2:09 pm on October 10, 2019:
    In python it is possible to capture the output in a string and then write it to a file

    MarcoFalke commented at 2:10 pm on October 10, 2019:

    or directly redirect the output to a file

    I am pretty sure we already do that in various places in our framework.



    fjahr commented at 0:06 am on October 13, 2019:
    Alright, I changed it do the output redirect in python now.
  5. fjahr force-pushed on Oct 10, 2019
  6. fjahr force-pushed on Oct 10, 2019
  7. DrahtBot commented at 1:12 am on October 11, 2019: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #17104 (build: make dist uses git archive by ch4ot1c)

    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.

  8. fjahr force-pushed on Oct 13, 2019
  9. tests: Add test for loadblock option 89339d1460
  10. fjahr force-pushed on Oct 13, 2019
  11. laanwj commented at 9:21 am on October 23, 2019: member
    ACK 89339d14607434b33cfa343dc75877b62b1dfe0e
  12. laanwj referenced this in commit 4258fd7377 on Oct 23, 2019
  13. laanwj merged this on Oct 23, 2019
  14. laanwj closed this on Oct 23, 2019

  15. MarcoFalke commented at 1:42 pm on October 23, 2019: member
    Thanks. ACK
  16. sidhujag referenced this in commit 3e3f53b757 on Oct 26, 2019
  17. deadalnix referenced this in commit c50ee9076a on Jun 11, 2020
  18. 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: 2024-11-21 15:12 UTC

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