Skip to content

Commit b223c3c

Browse files
committed
test: Add functional test for symlinked blocks directory
1 parent ddb75c2 commit b223c3c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@
321321
'rpc_getdescriptorinfo.py',
322322
'rpc_mempool_entry_fee_fields_deprecation.py',
323323
'rpc_help.py',
324+
'feature_dirsymlinks.py',
324325
'feature_help.py',
325326
'feature_shutdown.py',
326327
'p2p_ibd_txrelay.py',

0 commit comments

Comments
 (0)