mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Add missing dash-specific parts
This commit is contained in:
parent
9828b624a0
commit
4bfef1daad
@ -442,7 +442,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
self.stop_node(3)
|
||||
self.nodes[1].encryptwallet("test")
|
||||
self.nodes.pop(1)
|
||||
wait_node(1)
|
||||
self.wait_node(1)
|
||||
|
||||
self.nodes = self.start_nodes(4, self.options.tmpdir, [['-usehd=1']] * self.num_nodes, stderr=sys.stdout)
|
||||
# This test is not meant to test fee estimation and we'd like
|
||||
|
@ -232,6 +232,8 @@ class BitcoinTestFramework(object):
|
||||
if binary is None:
|
||||
binary = os.getenv("BITCOIND", "bitcoind")
|
||||
args = [binary, "-datadir=" + datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(self.mocktime), "-uacomment=testnode%d" % i]
|
||||
# Don't try auto backups (they fail a lot when running tests)
|
||||
args += [ "-createwalletbackups=0" ]
|
||||
if extra_args is not None:
|
||||
args.extend(extra_args)
|
||||
self.bitcoind_processes[i] = subprocess.Popen(args, stderr=stderr)
|
||||
@ -245,8 +247,8 @@ class BitcoinTestFramework(object):
|
||||
|
||||
return proxy
|
||||
|
||||
def start_nodes(self, num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None):
|
||||
"""Start multiple bitcoinds, return RPC connections to them"""
|
||||
def start_nodes(self, num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None):
|
||||
"""Start multiple dashds, return RPC connections to them"""
|
||||
|
||||
if extra_args is None:
|
||||
extra_args = [None] * num_nodes
|
||||
@ -257,7 +259,7 @@ class BitcoinTestFramework(object):
|
||||
rpcs = []
|
||||
try:
|
||||
for i in range(num_nodes):
|
||||
rpcs.append(self.start_node(i, dirname, extra_args[i], rpchost, timewait=timewait, binary=binary[i]))
|
||||
rpcs.append(self.start_node(i, dirname, extra_args[i], rpchost, timewait=timewait, binary=binary[i], stderr=stderr))
|
||||
except:
|
||||
# If one node failed to start, stop the others
|
||||
# TODO: abusing self.nodes in this way is a little hacky.
|
||||
@ -268,7 +270,7 @@ class BitcoinTestFramework(object):
|
||||
raise
|
||||
return rpcs
|
||||
|
||||
def stop_node(self, i):
|
||||
def _stop_node(self, node, i, wait=True):
|
||||
"""Stop a bitcoind test node"""
|
||||
|
||||
self.log.debug("Stopping node %d" % i)
|
||||
@ -276,15 +278,20 @@ class BitcoinTestFramework(object):
|
||||
self.nodes[i].stop()
|
||||
except http.client.CannotSendRequest as e:
|
||||
self.log.exception("Unable to stop node")
|
||||
return_code = self.bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
|
||||
del self.bitcoind_processes[i]
|
||||
assert_equal(return_code, 0)
|
||||
if wait:
|
||||
self.wait_node(i)
|
||||
|
||||
def stop_nodes(self):
|
||||
def stop_node(self, num_node):
|
||||
self._stop_node(self.nodes[num_node], num_node)
|
||||
|
||||
def stop_nodes(self, fast=True):
|
||||
"""Stop multiple bitcoind test nodes"""
|
||||
|
||||
for i in range(len(self.nodes)):
|
||||
self.stop_node(i)
|
||||
for i, node in enumerate(self.nodes):
|
||||
self._stop_node(node, i, not fast)
|
||||
if fast:
|
||||
for i, node in enumerate(self.nodes):
|
||||
self.wait_node(i)
|
||||
assert not self.bitcoind_processes.values() # All connections must be gone now
|
||||
|
||||
def assert_start_raises_init_error(self, i, dirname, extra_args=None, expected_msg=None):
|
||||
@ -306,6 +313,11 @@ class BitcoinTestFramework(object):
|
||||
assert_msg = "bitcoind should have exited with expected error " + expected_msg
|
||||
raise AssertionError(assert_msg)
|
||||
|
||||
def wait_node(self, i):
|
||||
return_code = self.bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
|
||||
assert_equal(return_code, 0)
|
||||
del self.bitcoind_processes[i]
|
||||
|
||||
def wait_for_node_exit(self, i, timeout):
|
||||
self.bitcoind_processes[i].wait(timeout)
|
||||
|
||||
|
@ -269,14 +269,22 @@ def get_auth_cookie(datadir, n):
|
||||
raise ValueError("No RPC credentials")
|
||||
return user, password
|
||||
|
||||
def copy_datadir(from_node, to_node, dirname):
|
||||
from_datadir = os.path.join(dirname, "node"+str(from_node), "regtest")
|
||||
to_datadir = os.path.join(dirname, "node"+str(to_node), "regtest")
|
||||
|
||||
dirs = ["blocks", "chainstate", "evodb", "llmq"]
|
||||
for d in dirs:
|
||||
try:
|
||||
src = os.path.join(from_datadir, d)
|
||||
dst = os.path.join(to_datadir, d)
|
||||
shutil.copytree(src, dst)
|
||||
except:
|
||||
pass
|
||||
|
||||
def log_filename(dirname, n_node, logname):
|
||||
return os.path.join(dirname, "node" + str(n_node), "regtest", logname)
|
||||
|
||||
def wait_node(i):
|
||||
return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
|
||||
assert_equal(return_code, 0)
|
||||
del bitcoind_processes[i]
|
||||
|
||||
def get_bip9_status(node, key):
|
||||
info = node.getblockchaininfo()
|
||||
return info['bip9_softforks'][key]
|
||||
@ -375,6 +383,10 @@ def sync_mempools(rpc_connections, *, wait=1, timeout=60):
|
||||
timeout -= wait
|
||||
raise AssertionError("Mempool sync failed")
|
||||
|
||||
def sync_masternodes(rpc_connections, fast_mnsync=False):
|
||||
for node in rpc_connections:
|
||||
wait_to_sync(node, fast_mnsync)
|
||||
|
||||
# Transaction/Block functions
|
||||
#############################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user