2018-03-09 05:43:55 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
"""Test the blocksdir option.
|
|
|
|
"""
|
|
|
|
|
2018-03-28 01:24:09 +02:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
2018-03-09 05:43:55 +01:00
|
|
|
from test_framework.test_framework import BitcoinTestFramework, initialize_datadir
|
|
|
|
|
|
|
|
|
|
|
|
class BlocksdirTest(BitcoinTestFramework):
|
|
|
|
def set_test_params(self):
|
|
|
|
self.setup_clean_chain = True
|
|
|
|
self.num_nodes = 1
|
|
|
|
|
2018-09-09 19:32:37 +02:00
|
|
|
def skip_test_if_missing_module(self):
|
|
|
|
self.skip_if_no_wallet()
|
|
|
|
|
2018-03-09 05:43:55 +01:00
|
|
|
def run_test(self):
|
|
|
|
self.stop_node(0)
|
2019-07-31 20:11:32 +02:00
|
|
|
assert os.path.isdir(os.path.join(self.nodes[0].datadir, self.chain, "blocks"))
|
2018-11-30 15:32:23 +01:00
|
|
|
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "blocks"))
|
2018-03-28 01:24:09 +02:00
|
|
|
shutil.rmtree(self.nodes[0].datadir)
|
2019-07-31 20:11:32 +02:00
|
|
|
initialize_datadir(self.options.tmpdir, 0, self.chain)
|
2018-08-16 00:18:26 +02:00
|
|
|
self.log.info("Starting with nonexistent blocksdir ...")
|
2018-03-28 01:24:09 +02:00
|
|
|
blocksdir_path = os.path.join(self.options.tmpdir, 'blocksdir')
|
|
|
|
self.start_node(0, ["-blocksdir=" + blocksdir_path])
|
2018-03-09 05:43:55 +01:00
|
|
|
self.log.info("mining blocks..")
|
2018-09-15 11:32:12 +02:00
|
|
|
self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address)
|
2020-02-13 16:41:28 +01:00
|
|
|
assert os.path.isfile(os.path.join(blocksdir_path, "regtest", "blk00000.dat"))
|
|
|
|
assert os.path.isfile(os.path.join(blocksdir_path, "regtest", "rev00000.dat"))
|
|
|
|
assert os.path.isfile(os.path.join(blocksdir_path, "regtest", "index.sqlite"))
|
2018-03-28 01:24:09 +02:00
|
|
|
|
2018-03-09 05:43:55 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
BlocksdirTest().main()
|