|
| 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() |
0 commit comments