|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (c) 2022 The Bitcoin Core developers |
| 3 | +# Distributed under the MIT software license, see the accompanying |
| 4 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 5 | +"""Test successful startup with symlinked directories. |
| 6 | +""" |
| 7 | + |
| 8 | +import os |
| 9 | +import sys |
| 10 | + |
| 11 | +from test_framework.test_framework import BitcoinTestFramework, SkipTest |
| 12 | + |
| 13 | + |
| 14 | +def rename_and_link(*, from_name, to_name): |
| 15 | + os.rename(from_name, to_name) |
| 16 | + os.symlink(to_name, from_name) |
| 17 | + assert os.path.islink(from_name) and os.path.isdir(from_name) |
| 18 | + |
| 19 | +class SymlinkTest(BitcoinTestFramework): |
| 20 | + def skip_test_if_missing_module(self): |
| 21 | + if sys.platform == 'win32': |
| 22 | + raise SkipTest("Symlinks test skipped on Windows") |
| 23 | + |
| 24 | + def set_test_params(self): |
| 25 | + self.num_nodes = 1 |
| 26 | + |
| 27 | + def run_test(self): |
| 28 | + self.stop_node(0) |
| 29 | + |
| 30 | + rename_and_link(from_name=os.path.join(self.nodes[0].datadir, self.chain, "blocks"), |
| 31 | + to_name=os.path.join(self.nodes[0].datadir, self.chain, "newblocks")) |
| 32 | + rename_and_link(from_name=os.path.join(self.nodes[0].datadir, self.chain, "chainstate"), |
| 33 | + to_name=os.path.join(self.nodes[0].datadir, self.chain, "newchainstate")) |
| 34 | + |
| 35 | + self.start_node(0) |
| 36 | + |
| 37 | + |
| 38 | +if __name__ == '__main__': |
| 39 | + SymlinkTest().main() |
0 commit comments