Skip to content

Commit

Permalink
test: add test for specifying custom pidfile via -pid
Browse files Browse the repository at this point in the history
  • Loading branch information
theStack committed Aug 27, 2024
1 parent e53b1c1 commit fc8faa2
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions test/functional/feature_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2021-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Stress tests related to node initialization."""
"""Tests related to node initialization."""
from pathlib import Path
import platform
import shutil
Expand All @@ -12,7 +12,11 @@
from test_framework.util import assert_equal


class InitStressTest(BitcoinTestFramework):
BITCOIN_PID_FILENAME_DEFAULT = "bitcoind.pid"
BITCOIN_PID_FILENAME_CUSTOM = "my_fancy_bitcoin_pid_file.foobar"


class InitTest(BitcoinTestFramework):
"""
Ensure that initialization can be interrupted at a number of points and not impair
subsequent starts.
Expand All @@ -25,7 +29,7 @@ def set_test_params(self):
self.setup_clean_chain = False
self.num_nodes = 1

def run_test(self):
def init_stress_test(self):
"""
- test terminating initialization after seeing a certain log line.
- test removing certain essential files to test startup error paths.
Expand Down Expand Up @@ -147,6 +151,19 @@ def check_clean_start():
shutil.move(node.chain_path / "blocks_bak", node.chain_path / "blocks")
shutil.move(node.chain_path / "chainstate_bak", node.chain_path / "chainstate")

def init_pid_test(self):
self.log.info("Test specifying custom pid file via -pid command line option")
self.restart_node(0, [f"-pid={BITCOIN_PID_FILENAME_CUSTOM}"])
datadir = self.nodes[0].chain_path
assert not (datadir / BITCOIN_PID_FILENAME_DEFAULT).exists()
assert (datadir / BITCOIN_PID_FILENAME_CUSTOM).exists()
self.stop_node(0)
assert not (datadir / BITCOIN_PID_FILENAME_CUSTOM).exists()

def run_test(self):
self.init_pid_test()
self.init_stress_test()


if __name__ == '__main__':
InitStressTest(__file__).main()
InitTest(__file__).main()

0 comments on commit fc8faa2

Please sign in to comment.