Skip to content

Commit 0387ca0

Browse files
committed
Merge bitcoin#28612: Test: followups to bitcoin#27823
5ab6419 test: randomized perturbing in feature_init (L0la L33tz) 64b80d5 test: simplify feature_init (Fabian Jahr) Pull request description: Fixes bitcoin#28603 Added suggested simplifications and implemented randomization ACKs for top commit: theStack: Light ACK 5ab6419 maflcko: lgtm ACK 5ab6419 achow101: ACK 5ab6419 Tree-SHA512: e6f43eef7f8dd12c7fccbe437cb430dc9d383825d7ab2caa0382d061f88dec6d28522e1ec78f3f58f26d35cba93512fa21e330c48d06b1d8141a16f07050af5a
2 parents 0f5e31c + 5ab6419 commit 0387ca0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/functional/feature_init.py

+4-6
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
@@ -133,15 +134,12 @@ def check_clean_start():
133134

134135
for target_file in target_files:
135136
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:
139138
# Since the genesis block is not checked by -checkblocks, the
140139
# perturbation window must be chosen such that a higher block
141140
# 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))
145143

146144
start_expecting_error(err_fragment)
147145

0 commit comments

Comments
 (0)