Skip to content

Commit c4fd6de

Browse files
committed
merge bitcoin#28612: followups to bitcoin#27823
1 parent 2588bcf commit c4fd6de

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/functional/feature_init.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""Stress tests related to node initialization."""
66
import os
77
from pathlib import Path
8+
from random import randint
89
import shutil
910

1011
from test_framework.test_framework import BitcoinTestFramework, SkipTest
@@ -131,15 +132,12 @@ def check_clean_start():
131132

132133
for target_file in target_files:
133134
self.log.info(f"Perturbing file to ensure failure {target_file}")
134-
with open(target_file, "rb") as tf_read:
135-
contents = tf_read.read()
136-
tweaked_contents = bytearray(contents)
135+
with open(target_file, "r+b") as tf:
137136
# Since the genesis block is not checked by -checkblocks, the
138137
# perturbation window must be chosen such that a higher block
139138
# in blk*.dat is affected.
140-
tweaked_contents[150:350] = b'1' * 200
141-
with open(target_file, "wb") as tf_write:
142-
tf_write.write(bytes(tweaked_contents))
139+
tf.seek(randint (150, 15000))
140+
tf.write(b'1' * randint(20, 2000))
143141

144142
start_expecting_error(err_fragment)
145143

0 commit comments

Comments
 (0)