diff options
author | Andrew Chow <github@achow101.com> | 2023-11-06 16:46:45 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-11-06 16:57:39 -0500 |
commit | 0387ca0774be0fa05a81cb91f880c53a7ad5fade (patch) | |
tree | a236dd0be549a13b9aa7e73d8fffa3c7b78d4986 | |
parent | 0f5e31ce7d743683527ede1c9c8033e22cd4554a (diff) | |
parent | 5ab6419f380cc0a8cde78b125f3eeee5fcba43ae (diff) |
Merge bitcoin/bitcoin#28612: Test: followups to #27823
5ab6419f380cc0a8cde78b125f3eeee5fcba43ae test: randomized perturbing in feature_init (L0la L33tz)
64b80d5c5bc1311cd2fb188f2d84aff6704e27d7 test: simplify feature_init (Fabian Jahr)
Pull request description:
Fixes #28603
Added suggested simplifications and implemented randomization
ACKs for top commit:
theStack:
Light ACK 5ab6419f380cc0a8cde78b125f3eeee5fcba43ae
maflcko:
lgtm ACK 5ab6419f380cc0a8cde78b125f3eeee5fcba43ae
achow101:
ACK 5ab6419f380cc0a8cde78b125f3eeee5fcba43ae
Tree-SHA512: e6f43eef7f8dd12c7fccbe437cb430dc9d383825d7ab2caa0382d061f88dec6d28522e1ec78f3f58f26d35cba93512fa21e330c48d06b1d8141a16f07050af5a
-rwxr-xr-x | test/functional/feature_init.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/test/functional/feature_init.py b/test/functional/feature_init.py index 94f5116f9b..37ef3de4dd 100755 --- a/test/functional/feature_init.py +++ b/test/functional/feature_init.py @@ -5,6 +5,7 @@ """Stress tests related to node initialization.""" import os from pathlib import Path +from random import randint import shutil from test_framework.test_framework import BitcoinTestFramework, SkipTest @@ -133,15 +134,12 @@ class InitStressTest(BitcoinTestFramework): for target_file in target_files: self.log.info(f"Perturbing file to ensure failure {target_file}") - with open(target_file, "rb") as tf_read: - contents = tf_read.read() - tweaked_contents = bytearray(contents) + with open(target_file, "r+b") as tf: # Since the genesis block is not checked by -checkblocks, the # perturbation window must be chosen such that a higher block # in blk*.dat is affected. - tweaked_contents[150:350] = b'1' * 200 - with open(target_file, "wb") as tf_write: - tf_write.write(bytes(tweaked_contents)) + tf.seek(randint (150, 15000)) + tf.write(b'1' * randint(20, 2000)) start_expecting_error(err_fragment) |