diff --git a/test/functional/conf_args.py b/test/functional/conf_args.py new file mode 100755 index 0000000000..88c48ab37b --- /dev/null +++ b/test/functional/conf_args.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +# Copyright (c) 2017 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 various command line arguments and configuration file parameters.""" +import time +import os + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import get_datadir_path + + +class ConfArgsTest(BitcoinTestFramework): + def set_test_params(self): + self.setup_clean_chain = True + self.num_nodes = 1 + + def run_test(self): + self.stop_node(0) + # Remove the -datadir argument so it doesn't override the config file + self.nodes[0].args = [ + arg for arg in self.nodes[0].args if not arg.startswith("-datadir")] + + default_data_dir = get_datadir_path(self.options.tmpdir, 0) + new_data_dir = os.path.join(default_data_dir, 'newdatadir') + new_data_dir_2 = os.path.join(default_data_dir, 'newdatadir2') + + # Check that using -datadir argument on non-existent directory fails + self.nodes[0].datadir = new_data_dir + self.assert_start_raises_init_error( + 0, ['-datadir='+new_data_dir], + 'Error: Specified data directory "' + new_data_dir + '" does not exist.') + + # Check that using non-existent datadir in conf file fails + conf_file = os.path.join(default_data_dir, "bitcoin.conf") + with open(conf_file, 'a', encoding='utf8') as f: + f.write("datadir=" + new_data_dir + "\n") + self.assert_start_raises_init_error( + 0, ['-conf='+conf_file], + 'Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.') + + # Create the directory and ensure the config file now works + os.mkdir(new_data_dir) + self.start_node(0, ['-conf='+conf_file, '-wallet=w1']) + time.sleep(5) + self.stop_node(0) + assert os.path.isfile(os.path.join( + new_data_dir, 'regtest', 'wallets', 'w1')) + + # Ensure command line argument overrides datadir in conf + os.mkdir(new_data_dir_2) + self.nodes[0].datadir = new_data_dir_2 + self.start_node(0, ['-datadir='+new_data_dir_2, + '-conf='+conf_file, '-wallet=w2']) + assert os.path.isfile(os.path.join( + new_data_dir_2, 'regtest', 'wallets', 'w2')) + + +if __name__ == '__main__': + ConfArgsTest().main() diff --git a/test/functional/timing.json b/test/functional/timing.json index d110423498..bdd1fe0081 100644 --- a/test/functional/timing.json +++ b/test/functional/timing.json @@ -1,370 +1,374 @@ [ { "name": "abandonconflict.py", "time": 18 }, { "name": "abc-checkdatasig-activation.py", "time": 5 }, { "name": "abc-cmdline.py", "time": 8 }, { "name": "abc-finalize-block.py", "time": 7 }, { "name": "abc-high_priority_transaction.py", "time": 16 }, { "name": "abc-magnetic-anomaly-activation.py", "time": 8 }, { "name": "abc-magnetic-anomaly-mining.py", "time": 19 }, { "name": "abc-mempool-accept-txn.py", "time": 10 }, { "name": "abc-p2p-compactblocks.py", "time": 743 }, { "name": "abc-p2p-fullblocktest.py", "time": 125 }, { "name": "abc-parkedchain.py", "time": 16 }, { "name": "abc-replay-protection.py", "time": 6 }, { "name": "abc-rpc.py", "time": 2 }, { "name": "abc-sync-chain.py", "time": 4 }, { "name": "abc-transaction-ordering.py", "time": 8 }, { "name": "assumevalid.py", "time": 66 }, { "name": "bip65-cltv-p2p.py", "time": 17 }, { "name": "bip68-112-113-p2p.py", "time": 28 }, { "name": "bip68-sequence.py", "time": 22 }, { "name": "bipdersig-p2p.py", "time": 46 }, { "name": "bitcoin_cli.py", "time": 3 }, { "name": "blockchain.py", "time": 11 }, { "name": "dbcrash.py", "time": 537 }, + { + "name": "conf_args.py", + "time": 13 + }, { "name": "decodescript.py", "time": 2 }, { "name": "disablewallet.py", "time": 2 }, { "name": "disconnect_ban.py", "time": 7 }, { "name": "example_test.py", "time": 3 }, { "name": "fundrawtransaction.py", "time": 42 }, { "name": "getblocktemplate_longpoll.py", "time": 68 }, { "name": "getchaintips.py", "time": 5 }, { "name": "httpbasics.py", "time": 3 }, { "name": "import-rescan.py", "time": 18 }, { "name": "importmulti.py", "time": 16 }, { "name": "importprunedfunds.py", "time": 5 }, { "name": "invalidateblock.py", "time": 8 }, { "name": "invalidblockrequest.py", "time": 5 }, { "name": "invalidtxrequest.py", "time": 6 }, { "name": "keypool-topup.py", "time": 18 }, { "name": "keypool.py", "time": 9 }, { "name": "listsinceblock.py", "time": 6 }, { "name": "listtransactions.py", "time": 7 }, { "name": "maxuploadtarget.py", "time": 29 }, { "name": "mempool_limit.py", "time": 7 }, { "name": "mempool_packages.py", "time": 70 }, { "name": "mempool_persist.py", "time": 19 }, { "name": "mempool_reorg.py", "time": 3 }, { "name": "mempool_resurrect_test.py", "time": 3 }, { "name": "mempool_spendcoinbase.py", "time": 2 }, { "name": "merkle_blocks.py", "time": 5 }, { "name": "minchainwork.py", "time": 7 }, { "name": "mining.py", "time": 3 }, { "name": "multi_rpc.py", "time": 4 }, { "name": "multiwallet.py", "time": 9 }, { "name": "net.py", "time": 3 }, { "name": "notifications.py", "time": 7 }, { "name": "nulldummy.py", "time": 6 }, { "name": "p2p-acceptblock.py", "time": 45 }, { "name": "p2p-compactblocks.py", "time": 21 }, { "name": "p2p-feefilter.py", "time": 26 }, { "name": "p2p-fingerprint.py", "time": 9 }, { "name": "p2p-fullblocktest.py", "time": 189 }, { "name": "p2p-leaktests.py", "time": 8 }, { "name": "p2p-mempool.py", "time": 3 }, { "name": "p2p-timeouts.py", "time": 65 }, { "name": "preciousblock.py", "time": 4 }, { "name": "prioritise_transaction.py", "time": 6 }, { "name": "proxy_test.py", "time": 4 }, { "name": "pruning.py", "time": 1039 }, { "name": "rawtransactions.py", "time": 16 }, { "name": "reindex.py", "time": 13 }, { "name": "resendwallettransactions.py", "time": 5 }, { "name": "rest.py", "time": 9 }, { "name": "rpcbind_test.py", "time": 24 }, { "name": "rpcnamedargs.py", "time": 3 }, { "name": "sendheaders.py", "time": 18 }, { "name": "signmessages.py", "time": 2 }, { "name": "signrawtransactions.py", "time": 2 }, { "name": "txn_clone.py", "time": 5 }, { "name": "txn_clone.py --mineblock", "time": 5 }, { "name": "txn_doublespend.py", "time": 5 }, { "name": "txn_doublespend.py --mineblock", "time": 5 }, { "name": "uacomment.py", "time": 6 }, { "name": "uptime.py", "time": 2 }, { "name": "wallet.py", "time": 67 }, { "name": "wallet_accounts.py", "time": 14 }, { "name": "wallet_dump.py", "time": 8 }, { "name": "wallet_encryption.py", "time": 9 }, { "name": "wallet_hd.py", "time": 122 }, { "name": "wallet_receivedby.py", "time": 9 }, { "name": "walletbackup.py", "time": 147 }, { "name": "zapwallettxes.py", "time": 12 }, { "name": "zmq_test.py", "time": 7 } ] \ No newline at end of file