File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 5
5
"""Stress tests related to node initialization."""
6
6
import os
7
7
from pathlib import Path
8
+ from random import randint
8
9
import shutil
9
10
10
11
from test_framework .test_framework import BitcoinTestFramework , SkipTest
@@ -133,15 +134,12 @@ def check_clean_start():
133
134
134
135
for target_file in target_files :
135
136
self .log .info (f"Perturbing file to ensure failure { target_file } " )
136
- with open (target_file , "rb" ) as tf_read :
137
- contents = tf_read .read ()
138
- tweaked_contents = bytearray (contents )
137
+ with open (target_file , "r+b" ) as tf :
139
138
# Since the genesis block is not checked by -checkblocks, the
140
139
# perturbation window must be chosen such that a higher block
141
140
# in blk*.dat is affected.
142
- tweaked_contents [150 :350 ] = b'1' * 200
143
- with open (target_file , "wb" ) as tf_write :
144
- tf_write .write (bytes (tweaked_contents ))
141
+ tf .seek (randint (150 , 15000 ))
142
+ tf .write (b'1' * randint (20 , 2000 ))
145
143
146
144
start_expecting_error (err_fragment )
147
145
You can’t perform that action at this time.
0 commit comments