Skip to content

Commit f38e4fd

Browse files
committed
QA: Add -blocksdir test
1 parent 386a6b6 commit f38e4fd

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

test/functional/feature_blocksdir.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2018 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 the blocksdir option.
6+
"""
7+
8+
from test_framework.test_framework import BitcoinTestFramework, initialize_datadir
9+
10+
import shutil
11+
import os
12+
13+
class BlocksdirTest(BitcoinTestFramework):
14+
def set_test_params(self):
15+
self.setup_clean_chain = True
16+
self.num_nodes = 1
17+
18+
def run_test(self):
19+
self.stop_node(0)
20+
node0path = os.path.join(self.options.tmpdir, "node0")
21+
shutil.rmtree(node0path)
22+
initialize_datadir(self.options.tmpdir, 0)
23+
self.log.info("Starting with non exiting blocksdir ...")
24+
self.assert_start_raises_init_error(0, ["-blocksdir="+self.options.tmpdir+ "/blocksdir"], "Specified blocks director")
25+
os.mkdir(self.options.tmpdir+ "/blocksdir")
26+
self.log.info("Starting with exiting blocksdir ...")
27+
self.start_node(0, ["-blocksdir="+self.options.tmpdir+ "/blocksdir"])
28+
self.log.info("mining blocks..")
29+
self.nodes[0].generate(10)
30+
assert(os.path.isfile(self.options.tmpdir+ "/blocksdir/regtest/blocks/blk00000.dat"))
31+
assert(os.path.isdir(self.options.tmpdir+ "/blocksdir/regtest/blocks/index"))
32+
33+
if __name__ == '__main__':
34+
BlocksdirTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
'p2p_unrequested_blocks.py',
134134
'feature_logging.py',
135135
'p2p_node_network_limited.py',
136+
'feature_blocksdir.py',
136137
'feature_config_args.py',
137138
# Don't append tests at the end to avoid merge conflicts
138139
# Put them in a random line within the section that fits their approximate run-time

0 commit comments

Comments
 (0)