2017-12-20 09:34:08 +01:00
#!/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 os
from test_framework . test_framework import BitcoinTestFramework
2018-03-22 11:04:37 +01:00
2017-12-20 09:34:08 +01:00
class ConfArgsTest ( BitcoinTestFramework ) :
def set_test_params ( self ) :
self . setup_clean_chain = True
self . num_nodes = 1
2019-12-09 19:52:38 +01:00
self . supports_cli = False
2017-12-20 09:34:08 +01:00
2018-09-06 12:52:06 +02:00
def test_config_file_parser ( self ) :
# Assume node is stopped
inc_conf_file_path = os . path . join ( self . nodes [ 0 ] . datadir , ' include.conf ' )
2021-07-19 20:00:59 +02:00
with open ( os . path . join ( self . nodes [ 0 ] . datadir , ' dash.conf ' ) , ' a ' , encoding = ' utf-8 ' ) as conf :
2018-09-06 12:52:06 +02:00
conf . write ( ' includeconf= {} \n ' . format ( inc_conf_file_path ) )
2019-06-20 22:59:10 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error (
2019-07-10 14:06:57 +02:00
expected_msg = ' Error: Error parsing command line arguments: Invalid parameter -dash_cli ' ,
2019-06-20 22:59:10 +02:00
extra_args = [ ' -dash_cli=1 ' ] ,
)
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' dash_conf=1 \n ' )
with self . nodes [ 0 ] . assert_debug_log ( expected_msgs = [ ' Ignoring unknown configuration value dash_conf ' ] ) :
self . start_node ( 0 )
self . stop_node ( 0 )
2018-09-06 12:52:06 +02:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' -dash=1 \n ' )
2019-07-10 14:06:57 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error ( expected_msg = ' Error: Error reading configuration file: parse error on line 1: -dash=1, options in configuration file must be specified without leading - ' )
2018-09-06 12:52:06 +02:00
merge bitcoin#16097: Add Flags enum to ArgsManager class (#4569)
* merge bitcoin#16097: Check IsArgKnown() early
* merge bitcoin#16097: Refactor InterpretNegatedOption() function
* merge bitcoin#16097: Add Flags enum to ArgsManager
* scripted-diff: Use Flags enum in AddArg()
-BEGIN VERIFY SCRIPT-
sed -i 's/const bool debug_only,/unsigned int flags, &/' src/util/system.h src/util/system.cpp
sed -i -E 's/(true|false), OptionsCategory::/ArgsManager::ALLOW_ANY, &/' $(git grep --files-with-matches 'AddArg(' src)
-END VERIFY SCRIPT-
* scripted-diff: Use ArgsManager::DEBUG_ONLY flag
-BEGIN VERIFY SCRIPT-
sed -i 's/unsigned int flags, const bool debug_only,/unsigned int flags,/' src/util/system.h src/util/system.cpp
sed -i 's/ArgsManager::NONE, debug_only/flags, false/' src/util/system.cpp
sed -i 's/arg.second.m_debug_only/(arg.second.m_flags \& ArgsManager::DEBUG_ONLY)/' src/util/system.cpp
sed -i 's/ArgsManager::ALLOW_ANY, true, OptionsCategory::/ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::/' $(git grep --files-with-matches 'AddArg(' src)
sed -i 's/ArgsManager::ALLOW_ANY, false, OptionsCategory::/ArgsManager::ALLOW_ANY, OptionsCategory::/' $(git grep --files-with-matches 'AddArg(' src)
-END VERIFY SCRIPT-
* merge bitcoin#16097: Remove unused m_debug_only member from Arg struct
* merge bitcoin#16097: Use ArgsManager::NETWORK_ONLY flag
* merge bitcoin#16097: Replace IsArgKnown() with FlagsOfKnownArg()
* merge bitcoin#16097: Revamp option negating policy
* merge bitcoin#16097: Make tests arg type specific
2021-11-13 01:25:46 +01:00
if self . is_wallet_compiled ( ) :
with open ( inc_conf_file_path , ' w ' , encoding = ' utf8 ' ) as conf :
conf . write ( " wallet=foo \n " )
2020-02-04 21:55:18 +01:00
self . nodes [ 0 ] . assert_start_raises_init_error ( expected_msg = ' Error: Config setting for -wallet only applied on %s network when in [ %s ] section. ' % ( self . chain , self . chain ) )
2021-10-17 04:03:18 +02:00
2019-07-16 22:07:14 +02:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' regtest=0 \n ' ) # mainnet
conf . write ( ' acceptnonstdtxn=1 \n ' )
self . nodes [ 0 ] . assert_start_raises_init_error ( expected_msg = ' Error: acceptnonstdtxn is not currently supported for main chain ' )
2018-09-06 12:52:06 +02:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' nono \n ' )
2019-07-10 14:06:57 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error ( expected_msg = ' Error: Error reading configuration file: parse error on line 1: nono, if you intended to specify a negated option, use nono=1 instead ' )
2018-09-06 12:52:06 +02:00
2018-11-12 15:20:30 +01:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' server=1 \n rpcuser=someuser \n rpcpassword=some#pass ' )
2019-07-10 14:06:57 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error ( expected_msg = ' Error: Error reading configuration file: parse error on line 3, using # in rpcpassword can be ambiguous and should be avoided ' )
2018-11-12 15:20:30 +01:00
2019-01-09 15:07:32 +01:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' server=1 \n rpcuser=someuser \n main.rpcpassword=some#pass ' )
2019-07-10 14:06:57 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error ( expected_msg = ' Error: Error reading configuration file: parse error on line 3, using # in rpcpassword can be ambiguous and should be avoided ' )
2019-01-09 15:07:32 +01:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' server=1 \n rpcuser=someuser \n [main] \n rpcpassword=some#pass ' )
2019-07-10 14:06:57 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error ( expected_msg = ' Error: Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided ' )
2019-01-09 15:07:32 +01:00
2019-03-02 15:59:09 +01:00
inc_conf_file2_path = os . path . join ( self . nodes [ 0 ] . datadir , ' include2.conf ' )
with open ( os . path . join ( self . nodes [ 0 ] . datadir , ' dash.conf ' ) , ' a ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' includeconf= {} \n ' . format ( inc_conf_file2_path ) )
Merge #14708: Warn unrecognised sections in the config file
3fb09b9889665a24b34f25e9d1385a05058a28b7 Warn unrecognized sections in the config file (Akio Nakamura)
Pull request description:
This PR intends to resolve #14702.
In the config file, sections are specified by square bracket pair "[]"$,
or included in the option name itself which separated by a period"(.)".
Typicaly, [testnet] is not a correct section name and specified options
in that section are ignored but user cannot recognize what is happen.
So, add some log-warning messages if unrecognized section names are
present in the config file after checking section only args.
note: Currentry, followings are out of scope of this PR.
1) Empty section name or option name can describe.
e.g. [] , .a=b, =c
2) Multiple period characters can exist in the section name and option name.
e.g. [c.d.e], [..], f.g.h.i=j, ..=k
Tree-SHA512: 2cea02a0525feb40320613989a75cd7b7b1bd12158d5e6f3174ca77e6a25bb84425dd8812f62483df9fc482045c7b5402d69bc714430518b1847d055a2dc304b
2018-11-21 16:43:46 +01:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
2019-03-02 15:59:09 +01:00
conf . write ( ' testnot.datadir=1 \n ' )
with open ( inc_conf_file2_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' [testnet] \n ' )
Merge #14708: Warn unrecognised sections in the config file
3fb09b9889665a24b34f25e9d1385a05058a28b7 Warn unrecognized sections in the config file (Akio Nakamura)
Pull request description:
This PR intends to resolve #14702.
In the config file, sections are specified by square bracket pair "[]"$,
or included in the option name itself which separated by a period"(.)".
Typicaly, [testnet] is not a correct section name and specified options
in that section are ignored but user cannot recognize what is happen.
So, add some log-warning messages if unrecognized section names are
present in the config file after checking section only args.
note: Currentry, followings are out of scope of this PR.
1) Empty section name or option name can describe.
e.g. [] , .a=b, =c
2) Multiple period characters can exist in the section name and option name.
e.g. [c.d.e], [..], f.g.h.i=j, ..=k
Tree-SHA512: 2cea02a0525feb40320613989a75cd7b7b1bd12158d5e6f3174ca77e6a25bb84425dd8812f62483df9fc482045c7b5402d69bc714430518b1847d055a2dc304b
2018-11-21 16:43:46 +01:00
self . restart_node ( 0 )
2020-06-01 10:05:15 +02:00
self . nodes [ 0 ] . stop_node ( expected_stderr = ' Warning: ' + inc_conf_file_path + ' :1 Section [testnot] is not recognized. ' + os . linesep + inc_conf_file2_path + ' :1 Section [testnet] is not recognized. ' )
Merge #14708: Warn unrecognised sections in the config file
3fb09b9889665a24b34f25e9d1385a05058a28b7 Warn unrecognized sections in the config file (Akio Nakamura)
Pull request description:
This PR intends to resolve #14702.
In the config file, sections are specified by square bracket pair "[]"$,
or included in the option name itself which separated by a period"(.)".
Typicaly, [testnet] is not a correct section name and specified options
in that section are ignored but user cannot recognize what is happen.
So, add some log-warning messages if unrecognized section names are
present in the config file after checking section only args.
note: Currentry, followings are out of scope of this PR.
1) Empty section name or option name can describe.
e.g. [] , .a=b, =c
2) Multiple period characters can exist in the section name and option name.
e.g. [c.d.e], [..], f.g.h.i=j, ..=k
Tree-SHA512: 2cea02a0525feb40320613989a75cd7b7b1bd12158d5e6f3174ca77e6a25bb84425dd8812f62483df9fc482045c7b5402d69bc714430518b1847d055a2dc304b
2018-11-21 16:43:46 +01:00
2018-09-06 12:52:06 +02:00
with open ( inc_conf_file_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' ' ) # clear
2019-03-02 15:59:09 +01:00
with open ( inc_conf_file2_path , ' w ' , encoding = ' utf-8 ' ) as conf :
conf . write ( ' ' ) # clear
2018-09-06 12:52:06 +02:00
2021-06-08 04:19:35 +02:00
def test_log_buffer ( self ) :
2020-01-11 00:37:33 +01:00
with self . nodes [ 0 ] . assert_debug_log ( expected_msgs = [ ' Warning: parsed potentially confusing double-negative -connect=0 \n ' ] ) :
2021-06-08 04:19:35 +02:00
self . start_node ( 0 , extra_args = [ ' -noconnect=0 ' ] )
self . stop_node ( 0 )
2020-01-30 23:10:50 +01:00
def test_args_log ( self ) :
self . log . info ( ' Test config args logging ' )
with self . nodes [ 0 ] . assert_debug_log (
expected_msgs = [
' Command-line arg: addnode= " some.node " ' ,
' Command-line arg: rpcauth=**** ' ,
' Command-line arg: rpcbind=**** ' ,
' Command-line arg: rpcpassword=**** ' ,
' Command-line arg: rpcuser=**** ' ,
' Command-line arg: torpassword=**** ' ,
2020-02-05 11:41:36 +01:00
' Config file arg: %s = " 1 " ' % self . chain ,
' Config file arg: [ %s ] server= " 1 " ' % self . chain ,
2020-01-30 23:10:50 +01:00
] ,
unexpected_msgs = [
' alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0 ' ,
' 127.1.1.1 ' ,
' secret-rpcuser ' ,
' secret-torpassword ' ,
] ) :
self . start_node ( 0 , extra_args = [
' -addnode=some.node ' ,
' -rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0 ' ,
' -rpcbind=127.1.1.1 ' ,
' -rpcpassword= ' ,
' -rpcuser=secret-rpcuser ' ,
' -torpassword=secret-torpassword ' ,
] )
self . stop_node ( 0 )
2017-12-20 09:34:08 +01:00
def run_test ( self ) :
self . stop_node ( 0 )
2021-06-08 04:19:35 +02:00
self . test_log_buffer ( )
2020-01-30 23:10:50 +01:00
self . test_args_log ( )
2021-06-08 04:19:35 +02:00
2018-09-06 12:52:06 +02:00
self . test_config_file_parser ( )
2017-12-20 09:34:08 +01:00
# 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 " ) ]
2018-03-22 11:04:37 +01:00
default_data_dir = self . nodes [ 0 ] . datadir
2017-12-20 09:34:08 +01:00
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
2021-04-08 22:29:01 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error ( [ ' -datadir= ' + new_data_dir ] , ' Error: Specified data directory " ' + new_data_dir + ' " does not exist. ' )
2017-12-20 09:34:08 +01:00
# Check that using non-existent datadir in conf file fails
2020-02-29 20:45:39 +01:00
conf_file = os . path . join ( default_data_dir , " dash.conf " )
Merge #11862: Network specific conf sections
c25321f Add config changes to release notes (Anthony Towns)
5e3cbe0 [tests] Unit tests for -testnet/-regtest in [test]/[regtest] sections (Anthony Towns)
005ad26 ArgsManager: special handling for -regtest and -testnet (Anthony Towns)
608415d [tests] Unit tests for network-specific config entries (Anthony Towns)
68797e2 ArgsManager: Warn when ignoring network-specific config setting (Anthony Towns)
d1fc4d9 ArgsManager: limit some options to only apply on mainnet when in default section (Anthony Towns)
8a9817d [tests] Use regtest section in functional tests configs (Anthony Towns)
30f9407 [tests] Unit tests for config file sections (Anthony Towns)
95eb66d ArgsManager: support config file sections (Anthony Towns)
4d34fcc ArgsManager: drop m_negated_args (Anthony Towns)
3673ca3 ArgsManager: keep command line and config file arguments separate (Anthony Towns)
Pull request description:
The weekly meeting on [2017-12-07](http://www.erisian.com.au/meetbot/bitcoin-core-dev/2017/bitcoin-core-dev.2017-12-07-19.00.log.html) discussed allowing options to bitcoin to have some sensitivity to what network is in use. @theuni suggested having sections in the config file:
<cfields> an alternative to that would be sections in a config file. and on the
cmdline they'd look like namespaces. so, [testnet] port=5. or -testnet::port=5.
This approach is (more or less) supported by `boost::program_options::detail::config_file_iterator` -- when it sees a `[testnet]` section with `port=5`, it will treat that the same as "testnet.port=5". So `[testnet] port=5` (or `testnet.port=5` without the section header) in bitcoin.conf and `-testnet.port=5` on the command line.
The other aspect to this question is possibly limiting some options so that there is no possibility of accidental cross-contamination across networks. For example, if you're using a particular wallet.dat on mainnet, you may not want to accidentally use the same wallet on testnet and risk reusing keys.
I've set this up so that the `-addnode` and `-wallet` options are `NETWORK_ONLY`, so that if you have a bitcoin.conf:
wallet=/secret/wallet.dat
upnp=1
and you run `bitcoind -testnet` or `bitcoind -regtest`, then the `wallet=` setting will be ignored, and should behave as if your bitcoin.conf had specified:
upnp=1
[main]
wallet=/secret/wallet.dat
For any `NETWORK_ONLY` options, if you're using `-testnet` or `-regtest`, you'll have to add the prefix to any command line options. This was necessary for `multiwallet.py` for instance.
I've left the "default" options as taking precedence over network specific ones, which might be backwards. So if you have:
maxmempool=200
[regtest]
maxmempool=100
your maxmempool will still be 200 on regtest. The advantage of doing it this way is that if you have `[regtest] maxmempool=100` in bitcoin.conf, and then say `bitcoind -regtest -maxmempool=200`, the same result is probably in line with what you expect...
The other thing to note is that I'm using the chain names from `chainparamsbase.cpp` / `ChainNameFromCommandLine`, so the sections are `[main]`, `[test]` and `[regtest]`; not `[mainnet]` or `[testnet]` as might be expected.
Thoughts? Ping @MeshCollider @laanwj @jonasschnelli @morcos
Tree-SHA512: f00b5eb75f006189987e5c15e154a42b66ee251777768c1e185d764279070fcb7c41947d8794092b912a03d985843c82e5189871416995436a6260520fb7a4db
2020-04-29 14:50:51 +02:00
2021-01-22 15:58:07 +01:00
# datadir needs to be set before [chain] section
Merge #11862: Network specific conf sections
c25321f Add config changes to release notes (Anthony Towns)
5e3cbe0 [tests] Unit tests for -testnet/-regtest in [test]/[regtest] sections (Anthony Towns)
005ad26 ArgsManager: special handling for -regtest and -testnet (Anthony Towns)
608415d [tests] Unit tests for network-specific config entries (Anthony Towns)
68797e2 ArgsManager: Warn when ignoring network-specific config setting (Anthony Towns)
d1fc4d9 ArgsManager: limit some options to only apply on mainnet when in default section (Anthony Towns)
8a9817d [tests] Use regtest section in functional tests configs (Anthony Towns)
30f9407 [tests] Unit tests for config file sections (Anthony Towns)
95eb66d ArgsManager: support config file sections (Anthony Towns)
4d34fcc ArgsManager: drop m_negated_args (Anthony Towns)
3673ca3 ArgsManager: keep command line and config file arguments separate (Anthony Towns)
Pull request description:
The weekly meeting on [2017-12-07](http://www.erisian.com.au/meetbot/bitcoin-core-dev/2017/bitcoin-core-dev.2017-12-07-19.00.log.html) discussed allowing options to bitcoin to have some sensitivity to what network is in use. @theuni suggested having sections in the config file:
<cfields> an alternative to that would be sections in a config file. and on the
cmdline they'd look like namespaces. so, [testnet] port=5. or -testnet::port=5.
This approach is (more or less) supported by `boost::program_options::detail::config_file_iterator` -- when it sees a `[testnet]` section with `port=5`, it will treat that the same as "testnet.port=5". So `[testnet] port=5` (or `testnet.port=5` without the section header) in bitcoin.conf and `-testnet.port=5` on the command line.
The other aspect to this question is possibly limiting some options so that there is no possibility of accidental cross-contamination across networks. For example, if you're using a particular wallet.dat on mainnet, you may not want to accidentally use the same wallet on testnet and risk reusing keys.
I've set this up so that the `-addnode` and `-wallet` options are `NETWORK_ONLY`, so that if you have a bitcoin.conf:
wallet=/secret/wallet.dat
upnp=1
and you run `bitcoind -testnet` or `bitcoind -regtest`, then the `wallet=` setting will be ignored, and should behave as if your bitcoin.conf had specified:
upnp=1
[main]
wallet=/secret/wallet.dat
For any `NETWORK_ONLY` options, if you're using `-testnet` or `-regtest`, you'll have to add the prefix to any command line options. This was necessary for `multiwallet.py` for instance.
I've left the "default" options as taking precedence over network specific ones, which might be backwards. So if you have:
maxmempool=200
[regtest]
maxmempool=100
your maxmempool will still be 200 on regtest. The advantage of doing it this way is that if you have `[regtest] maxmempool=100` in bitcoin.conf, and then say `bitcoind -regtest -maxmempool=200`, the same result is probably in line with what you expect...
The other thing to note is that I'm using the chain names from `chainparamsbase.cpp` / `ChainNameFromCommandLine`, so the sections are `[main]`, `[test]` and `[regtest]`; not `[mainnet]` or `[testnet]` as might be expected.
Thoughts? Ping @MeshCollider @laanwj @jonasschnelli @morcos
Tree-SHA512: f00b5eb75f006189987e5c15e154a42b66ee251777768c1e185d764279070fcb7c41947d8794092b912a03d985843c82e5189871416995436a6260520fb7a4db
2020-04-29 14:50:51 +02:00
conf_file_contents = open ( conf_file , encoding = ' utf8 ' ) . read ( )
with open ( conf_file , ' w ' , encoding = ' utf8 ' ) as f :
2017-12-20 09:34:08 +01:00
f . write ( " datadir= " + new_data_dir + " \n " )
Merge #11862: Network specific conf sections
c25321f Add config changes to release notes (Anthony Towns)
5e3cbe0 [tests] Unit tests for -testnet/-regtest in [test]/[regtest] sections (Anthony Towns)
005ad26 ArgsManager: special handling for -regtest and -testnet (Anthony Towns)
608415d [tests] Unit tests for network-specific config entries (Anthony Towns)
68797e2 ArgsManager: Warn when ignoring network-specific config setting (Anthony Towns)
d1fc4d9 ArgsManager: limit some options to only apply on mainnet when in default section (Anthony Towns)
8a9817d [tests] Use regtest section in functional tests configs (Anthony Towns)
30f9407 [tests] Unit tests for config file sections (Anthony Towns)
95eb66d ArgsManager: support config file sections (Anthony Towns)
4d34fcc ArgsManager: drop m_negated_args (Anthony Towns)
3673ca3 ArgsManager: keep command line and config file arguments separate (Anthony Towns)
Pull request description:
The weekly meeting on [2017-12-07](http://www.erisian.com.au/meetbot/bitcoin-core-dev/2017/bitcoin-core-dev.2017-12-07-19.00.log.html) discussed allowing options to bitcoin to have some sensitivity to what network is in use. @theuni suggested having sections in the config file:
<cfields> an alternative to that would be sections in a config file. and on the
cmdline they'd look like namespaces. so, [testnet] port=5. or -testnet::port=5.
This approach is (more or less) supported by `boost::program_options::detail::config_file_iterator` -- when it sees a `[testnet]` section with `port=5`, it will treat that the same as "testnet.port=5". So `[testnet] port=5` (or `testnet.port=5` without the section header) in bitcoin.conf and `-testnet.port=5` on the command line.
The other aspect to this question is possibly limiting some options so that there is no possibility of accidental cross-contamination across networks. For example, if you're using a particular wallet.dat on mainnet, you may not want to accidentally use the same wallet on testnet and risk reusing keys.
I've set this up so that the `-addnode` and `-wallet` options are `NETWORK_ONLY`, so that if you have a bitcoin.conf:
wallet=/secret/wallet.dat
upnp=1
and you run `bitcoind -testnet` or `bitcoind -regtest`, then the `wallet=` setting will be ignored, and should behave as if your bitcoin.conf had specified:
upnp=1
[main]
wallet=/secret/wallet.dat
For any `NETWORK_ONLY` options, if you're using `-testnet` or `-regtest`, you'll have to add the prefix to any command line options. This was necessary for `multiwallet.py` for instance.
I've left the "default" options as taking precedence over network specific ones, which might be backwards. So if you have:
maxmempool=200
[regtest]
maxmempool=100
your maxmempool will still be 200 on regtest. The advantage of doing it this way is that if you have `[regtest] maxmempool=100` in bitcoin.conf, and then say `bitcoind -regtest -maxmempool=200`, the same result is probably in line with what you expect...
The other thing to note is that I'm using the chain names from `chainparamsbase.cpp` / `ChainNameFromCommandLine`, so the sections are `[main]`, `[test]` and `[regtest]`; not `[mainnet]` or `[testnet]` as might be expected.
Thoughts? Ping @MeshCollider @laanwj @jonasschnelli @morcos
Tree-SHA512: f00b5eb75f006189987e5c15e154a42b66ee251777768c1e185d764279070fcb7c41947d8794092b912a03d985843c82e5189871416995436a6260520fb7a4db
2020-04-29 14:50:51 +02:00
f . write ( conf_file_contents )
2018-07-18 15:23:20 +02:00
2019-04-29 21:46:34 +02:00
self . nodes [ 0 ] . assert_start_raises_init_error ( [ ' -conf= ' + conf_file ] , ' Error: Error reading configuration file: specified data directory " ' + new_data_dir + ' " does not exist. ' )
2017-12-20 09:34:08 +01:00
# Create the directory and ensure the config file now works
os . mkdir ( new_data_dir )
2018-07-18 15:23:20 +02:00
# Temporarily disabled, because this test would access the user's home dir (~/.bitcoin)
2019-04-29 21:46:34 +02:00
self . start_node ( 0 , [ ' -conf= ' + conf_file , ' -wallet=w1 ' ] )
self . stop_node ( 0 )
assert os . path . exists ( os . path . join ( new_data_dir , self . chain , ' blocks ' ) )
if self . is_wallet_compiled ( ) :
assert os . path . exists ( os . path . join ( new_data_dir , self . chain , ' wallets ' , ' w1 ' ) )
2017-12-20 09:34:08 +01:00
# 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 ' ] )
2018-10-08 06:39:53 +02:00
assert os . path . exists ( os . path . join ( new_data_dir_2 , self . chain , ' blocks ' ) )
if self . is_wallet_compiled ( ) :
assert os . path . exists ( os . path . join ( new_data_dir_2 , self . chain , ' wallets ' , ' w2 ' ) )
2017-12-20 09:34:08 +01:00
if __name__ == ' __main__ ' :
ConfArgsTest ( ) . main ( )