From 6ea64b2e2a48f1c8618b0ff07e08c784e5741b59 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:58:18 +0200 Subject: [PATCH] merge bitcoin#28612: followups to bitcoin#27823 --- test/functional/feature_init.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/functional/feature_init.py b/test/functional/feature_init.py index 93f0858cb6457..b4227e65fd545 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 @@ -131,15 +132,12 @@ def check_clean_start(): 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)