Skip to content

Commit

Permalink
Merge bitcoin#28612: Test: followups to bitcoin#27823
Browse files Browse the repository at this point in the history
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
  • Loading branch information
achow101 committed Nov 6, 2023
2 parents 0f5e31c + 5ab6419 commit 0387ca0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/functional/feature_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,15 +134,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)

Expand Down

0 comments on commit 0387ca0

Please sign in to comment.