mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
4aa197dbdb
fa4632c41714dfaa699bacc6a947d72668a4deef test: Move boost/stdlib includes last (MarcoFalke) fa488f131fd4f5bab0d01376c5a5013306f1abcd scripted-diff: Bump copyright headers (MarcoFalke) fac5c373006a9e4bcbb56843bb85f1aca4d87599 scripted-diff: Sort test includes (MarcoFalke) Pull request description: When writing tests, often includes need to be added or removed. Currently the list of includes is not sorted, so developers that write tests and have `clang-format` installed will either have an unrelated change (sorting) included in their commit or they will have to manually undo the sort. This pull preempts both issues by just sorting all includes in one commit. Please be aware that this is **NOT** a change to policy to enforce clang-format or any other developer guideline or process. Developers are free to use whatever tool they want, see also #18651. Edit: Also includes a commit to bump the copyright headers, so that the touched files don't need to be touched again for that. ACKs for top commit: practicalswift: ACK fa4632c41714dfaa699bacc6a947d72668a4deef jonatack: ACK fa4632c41714dfaa, light review and sanity checks with gcc build and clang fuzz build Tree-SHA512: 130a8d073a379ba556b1e64104d37c46b671425c0aef0ed725fd60156a95e8dc83fb6f0b5330b2f8152cf5daaf3983b4aca5e75812598f2626c39fd12b88b180
84 lines
3.5 KiB
Python
Executable File
84 lines
3.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2017-2020 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 loadblock option
|
|
|
|
Test the option to start a node with the option loadblock which loads
|
|
a serialized blockchain from a file (usually called bootstrap.dat).
|
|
To generate that file this test uses the helper scripts available
|
|
in contrib/linearize.
|
|
"""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import urllib
|
|
|
|
from test_framework.blocktools import COINBASE_MATURITY
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import assert_equal
|
|
|
|
|
|
class LoadblockTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.setup_clean_chain = True
|
|
self.num_nodes = 2
|
|
self.supports_cli = False
|
|
|
|
def run_test(self):
|
|
self.nodes[1].setnetworkactive(state=False)
|
|
self.nodes[0].generate(COINBASE_MATURITY)
|
|
|
|
# Parsing the url of our node to get settings for config file
|
|
data_dir = self.nodes[0].datadir
|
|
node_url = urllib.parse.urlparse(self.nodes[0].url)
|
|
cfg_file = os.path.join(data_dir, "linearize.cfg")
|
|
bootstrap_file = os.path.join(self.options.tmpdir, "bootstrap.dat")
|
|
genesis_block = self.nodes[0].getblockhash(0)
|
|
blocks_dir = os.path.join(data_dir, self.chain, "blocks")
|
|
hash_list = tempfile.NamedTemporaryFile(dir=data_dir,
|
|
mode='w',
|
|
delete=False,
|
|
encoding="utf-8")
|
|
|
|
self.log.info("Create linearization config file")
|
|
with open(cfg_file, "a", encoding="utf-8") as cfg:
|
|
cfg.write("datadir={}\n".format(data_dir))
|
|
cfg.write("rpcuser={}\n".format(node_url.username))
|
|
cfg.write("rpcpassword={}\n".format(node_url.password))
|
|
cfg.write("port={}\n".format(node_url.port))
|
|
cfg.write("host={}\n".format(node_url.hostname))
|
|
cfg.write("output_file={}\n".format(bootstrap_file))
|
|
cfg.write("max_height=100\n")
|
|
cfg.write("netmagic=fcc1b7dc\n")
|
|
cfg.write("input={}\n".format(blocks_dir))
|
|
cfg.write("genesis={}\n".format(genesis_block))
|
|
cfg.write("hashlist={}\n".format(hash_list.name))
|
|
|
|
base_dir = self.config["environment"]["SRCDIR"]
|
|
linearize_dir = os.path.join(base_dir, "contrib", "linearize")
|
|
|
|
self.log.info("Run linearization of block hashes")
|
|
linearize_hashes_file = os.path.join(linearize_dir, "linearize-hashes.py")
|
|
subprocess.run([sys.executable, linearize_hashes_file, cfg_file],
|
|
stdout=hash_list,
|
|
check=True)
|
|
|
|
self.log.info("Run linearization of block data")
|
|
linearize_data_file = os.path.join(linearize_dir, "linearize-data.py")
|
|
subprocess.run([sys.executable, linearize_data_file, cfg_file],
|
|
check=True)
|
|
|
|
self.log.info("Restart second, unsynced node with bootstrap file")
|
|
self.restart_node(1, extra_args=["-loadblock=" + bootstrap_file])
|
|
assert_equal(self.nodes[1].getblockcount(), 100) # start_node is blocking on all block files being imported
|
|
|
|
assert_equal(self.nodes[1].getblockchaininfo()['blocks'], 100)
|
|
assert_equal(self.nodes[0].getbestblockhash(), self.nodes[1].getbestblockhash())
|
|
|
|
|
|
if __name__ == '__main__':
|
|
LoadblockTest().main()
|