mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Allow to pass extra dashd args when running tests
This commit is contained in:
parent
ea81ab5af7
commit
a6d6c94a74
@ -74,6 +74,7 @@ class BitcoinTestFramework():
|
||||
self.nodes = []
|
||||
self.mocktime = 0
|
||||
self.supports_cli = False
|
||||
self.extra_args_from_options = []
|
||||
self.set_test_params()
|
||||
|
||||
assert hasattr(self, "num_nodes"), "Test must set self.num_nodes in set_test_params()"
|
||||
@ -105,6 +106,8 @@ class BitcoinTestFramework():
|
||||
help="Attach a python debugger if test fails")
|
||||
parser.add_option("--usecli", dest="usecli", default=False, action="store_true",
|
||||
help="use bitcoin-cli instead of RPC for all commands")
|
||||
parser.add_option("--dashd-arg", dest="dashd_extra_args", default=[], type='string', action='append',
|
||||
help="Pass extra args to all dashd instances")
|
||||
self.add_options(parser)
|
||||
(self.options, self.args) = parser.parse_args()
|
||||
|
||||
@ -116,6 +119,8 @@ class BitcoinTestFramework():
|
||||
|
||||
self.options.cachedir = os.path.abspath(self.options.cachedir)
|
||||
|
||||
self.extra_args_from_options = self.options.dashd_extra_args
|
||||
|
||||
# Set up temp directory and start logging
|
||||
if self.options.tmpdir:
|
||||
self.options.tmpdir = os.path.abspath(self.options.tmpdir)
|
||||
@ -254,7 +259,7 @@ class BitcoinTestFramework():
|
||||
assert_equal(len(binary), num_nodes)
|
||||
old_num_nodes = len(self.nodes)
|
||||
for i in range(num_nodes):
|
||||
self.nodes.append(TestNode(old_num_nodes + i, self.options.tmpdir, extra_args[i], rpchost, timewait=timewait, binary=binary[i], stderr=stderr, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, use_cli=self.options.usecli))
|
||||
self.nodes.append(TestNode(old_num_nodes + i, self.options.tmpdir, extra_args[i], self.extra_args_from_options, rpchost, timewait=timewait, binary=binary[i], stderr=stderr, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, use_cli=self.options.usecli))
|
||||
|
||||
def start_node(self, i, *args, **kwargs):
|
||||
"""Start a dashd"""
|
||||
@ -446,7 +451,7 @@ class BitcoinTestFramework():
|
||||
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
||||
if extra_args is not None:
|
||||
args.extend(extra_args)
|
||||
self.nodes.append(TestNode(i, self.options.cachedir, extra_args=[], rpchost=None, timewait=None, binary=None, stderr=stderr, mocktime=self.mocktime, coverage_dir=None))
|
||||
self.nodes.append(TestNode(i, self.options.cachedir, extra_args=[], extra_args_from_options=self.extra_args_from_options, rpchost=None, timewait=None, binary=None, stderr=stderr, mocktime=self.mocktime, coverage_dir=None))
|
||||
self.nodes[i].args = args
|
||||
self.start_node(i)
|
||||
|
||||
|
@ -44,7 +44,7 @@ class TestNode():
|
||||
To make things easier for the test writer, any unrecognised messages will
|
||||
be dispatched to the RPC connection."""
|
||||
|
||||
def __init__(self, i, dirname, extra_args, rpchost, timewait, binary, stderr, mocktime, coverage_dir, use_cli=False):
|
||||
def __init__(self, i, dirname, extra_args, extra_args_from_options, rpchost, timewait, binary, stderr, mocktime, coverage_dir, use_cli=False):
|
||||
self.index = i
|
||||
self.datadir = os.path.join(dirname, "node" + str(i))
|
||||
self.rpchost = rpchost
|
||||
@ -62,6 +62,7 @@ class TestNode():
|
||||
self.mocktime = mocktime
|
||||
# Most callers will just need to add extra args to the standard list below. For those callers that need more flexibity, they can just set the args property directly.
|
||||
self.extra_args = extra_args
|
||||
self.extra_args_from_options = extra_args_from_options
|
||||
self.args = [self.binary, "-datadir=" + self.datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(mocktime), "-uacomment=testnode%d" % i]
|
||||
|
||||
self.cli = TestNodeCLI(os.getenv("BITCOINCLI", "dash-cli"), self.datadir)
|
||||
@ -104,7 +105,7 @@ class TestNode():
|
||||
extra_args = self.extra_args
|
||||
if stderr is None:
|
||||
stderr = self.stderr
|
||||
all_args = self.args + extra_args
|
||||
all_args = self.args + self.extra_args_from_options + extra_args
|
||||
if self.mocktime != 0:
|
||||
all_args = all_args + ["-mocktime=%d" % self.mocktime]
|
||||
# Delete any existing cookie file -- if such a file exists (eg due to
|
||||
|
Loading…
Reference in New Issue
Block a user