test, init: perturb file to ensure failure instead of only deleting them #26653

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2022-12-stress-test-perturbing changing 1 files +29 −19
  1. brunoerg commented at 5:12 PM on December 7, 2022: contributor

    In feature_init.py there is a TODO about perturbing the files instead of only testing by deleting them.

                # TODO: at some point, we should test perturbing the files instead of removing
                # them, e.g.
                #
                # contents = target_file.read_bytes()
                # tweaked_contents = bytearray(contents)
                # tweaked_contents[50:250] = b'1' * 200
                # target_file.write_bytes(bytes(tweaked_contents))
                #
                # At the moment I can't get this to work (bitcoind loads successfully?) so
                # investigate doing this later.
    

    This PR adds it by writing into the file random bytes and checking whether it throws an error when starting.

  2. DrahtBot commented at 5:12 PM on December 7, 2022: 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 MarcoFalke

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. fanquake requested review from jamesob on Dec 7, 2022
  4. fanquake added the label Tests on Dec 7, 2022
  5. brunoerg renamed this:
    test, init: perturb file to ensure failure instead of only deleting them
    [WIP] test, init: perturb file to ensure failure instead of only deleting them
    on Dec 7, 2022
  6. test, init: perturb file to ensure failure instead of only deleting them c371cae07a
  7. brunoerg force-pushed on Dec 7, 2022
  8. brunoerg renamed this:
    [WIP] test, init: perturb file to ensure failure instead of only deleting them
    test, init: perturb file to ensure failure instead of only deleting them
    on Dec 7, 2022
  9. brunoerg marked this as ready for review on Dec 7, 2022
  10. achow101 requested review from maflcko on Apr 25, 2023
  11. maflcko commented at 12:43 PM on May 5, 2023: member

    lgtm ACK c371cae07a7ba045130568b6abc470eaa4f95ef4

  12. DrahtBot removed review request from maflcko on May 5, 2023
  13. fanquake merged this on May 5, 2023
  14. fanquake closed this on May 5, 2023

  15. sidhujag referenced this in commit 949b32279b on May 5, 2023
  16. in test/functional/feature_init.py:132 in c371cae07a
     123 | @@ -126,6 +124,18 @@ def check_clean_start():
     124 |              check_clean_start()
     125 |              self.stop_node(0)
     126 |  
     127 | +        for file_patt, err_fragment in files_to_perturb.items():
     128 | +            target_files = list(node.chain_path.glob(file_patt))
     129 | +
     130 | +            for target_file in target_files:
     131 | +                self.log.info(f"Perturbing file to ensure failure {target_file}")
     132 | +                with open(target_file, "rb") as tf_read, open(target_file, "wb") as tf_write:
    


    fanquake commented at 9:45 AM on June 5, 2023:

    Note that it looks like this didn't work, and is being fixed in #27823.

  17. bitcoin locked this on Jun 4, 2024


jamesob

Labels

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-05-02 03:13 UTC

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