Introduce redirect_stderr argument to start_node
Also call it with redirect_stderr=True in all cases were non-critical warnings are expected.
This commit is contained in:
parent
fbe36d3db6
commit
21aaf92896
@ -14,7 +14,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
initialize_chain_clean(self.options.tmpdir, 4)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1'], ['-usehd=1'], ['-usehd=1'], ['-usehd=1']])
|
||||
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1'], ['-usehd=1'], ['-usehd=1'], ['-usehd=1']], redirect_stderr=True)
|
||||
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
@ -444,7 +444,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
stop_nodes(self.nodes)
|
||||
wait_bitcoinds()
|
||||
|
||||
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1'], ['-usehd=1'], ['-usehd=1'], ['-usehd=1']])
|
||||
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1'], ['-usehd=1'], ['-usehd=1'], ['-usehd=1']], redirect_stderr=True)
|
||||
# This test is not meant to test fee estimation and we'd like
|
||||
# to be sure all txs are sent at a consistent desired feerate
|
||||
for node in self.nodes:
|
||||
|
@ -23,7 +23,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
||||
nodes[0].encryptwallet('test')
|
||||
bitcoind_processes[0].wait()
|
||||
# Restart node 0
|
||||
nodes[0] = start_node(0, self.options.tmpdir, ['-usehd=1'])
|
||||
nodes[0] = start_node(0, self.options.tmpdir, ['-usehd=1'], redirect_stderr=True)
|
||||
# Keep creating keys
|
||||
addr = nodes[0].getnewaddress()
|
||||
addr_data = nodes[0].validateaddress(addr)
|
||||
@ -103,7 +103,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
||||
initialize_chain_clean(self.options.tmpdir, 1)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = start_nodes(1, self.options.tmpdir, [['-usehd=1']])
|
||||
self.nodes = start_nodes(1, self.options.tmpdir, [['-usehd=1']], redirect_stderr=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
KeyPoolTest().main()
|
||||
|
@ -306,7 +306,7 @@ def _rpchost_to_args(rpchost):
|
||||
rv += ['-rpcport=' + rpcport]
|
||||
return rv
|
||||
|
||||
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None):
|
||||
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, redirect_stderr=False):
|
||||
"""
|
||||
Start a dashd and return RPC connection to it
|
||||
"""
|
||||
@ -318,7 +318,14 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
||||
# 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)
|
||||
bitcoind_processes[i] = subprocess.Popen(args)
|
||||
|
||||
# Allow to redirect stderr to stdout in case we expect some non-critical warnings/errors printed to stderr
|
||||
# Otherwise the whole test would be considered to be failed in such cases
|
||||
stderr = None
|
||||
if redirect_stderr:
|
||||
stderr = subprocess.STDOUT
|
||||
|
||||
bitcoind_processes[i] = subprocess.Popen(args, stderr=stderr)
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print("start_node: dashd started, waiting for RPC to come up")
|
||||
url = rpc_url(i, rpchost)
|
||||
@ -332,7 +339,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
||||
|
||||
return proxy
|
||||
|
||||
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):
|
||||
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None, redirect_stderr=False):
|
||||
"""
|
||||
Start multiple dashds, return RPC connections to them
|
||||
"""
|
||||
@ -341,7 +348,7 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):
|
||||
rpcs = []
|
||||
try:
|
||||
for i in range(num_nodes):
|
||||
rpcs.append(start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]))
|
||||
rpcs.append(start_node(i, dirname, extra_args[i], rpchost, binary=binary[i], redirect_stderr=redirect_stderr))
|
||||
except: # If one node failed to start, stop the others
|
||||
stop_nodes(rpcs)
|
||||
raise
|
||||
|
@ -14,7 +14,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
initialize_chain_clean(self.options.tmpdir, 2)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = start_nodes(2, self.options.tmpdir, [['-usehd=0'], ['-usehd=1', '-keypool=0']])
|
||||
self.nodes = start_nodes(2, self.options.tmpdir, [['-usehd=0'], ['-usehd=1', '-keypool=0']], redirect_stderr=True)
|
||||
self.is_network_split = False
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
self.is_network_split=False
|
||||
@ -26,13 +26,13 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
# Make sure can't switch off usehd after wallet creation
|
||||
stop_node(self.nodes[1],1)
|
||||
try:
|
||||
start_node(1, self.options.tmpdir, ['-usehd=0'])
|
||||
start_node(1, self.options.tmpdir, ['-usehd=0'], redirect_stderr=True)
|
||||
raise AssertionError("Must not allow to turn off HD on an already existing HD wallet")
|
||||
except Exception as e:
|
||||
assert("dashd exited with status 1 during initialization" in str(e))
|
||||
# assert_start_raises_init_error(1, self.options.tmpdir, ['-usehd=0'], 'already existing HD wallet')
|
||||
# self.nodes[1] = start_node(1, self.options.tmpdir, self.node_args[1])
|
||||
self.nodes[1] = start_node(1, self.options.tmpdir, ['-usehd=1', '-keypool=0'])
|
||||
self.nodes[1] = start_node(1, self.options.tmpdir, ['-usehd=1', '-keypool=0'], redirect_stderr=True)
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
|
||||
# Make sure we use hd, keep chainid
|
||||
@ -79,7 +79,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
stop_node(self.nodes[1],1)
|
||||
os.remove(self.options.tmpdir + "/node1/regtest/wallet.dat")
|
||||
shutil.copyfile(tmpdir + "/hd.bak", tmpdir + "/node1/regtest/wallet.dat")
|
||||
self.nodes[1] = start_node(1, self.options.tmpdir, ['-usehd=1', '-keypool=0'])
|
||||
self.nodes[1] = start_node(1, self.options.tmpdir, ['-usehd=1', '-keypool=0'], redirect_stderr=True)
|
||||
#connect_nodes_bi(self.nodes, 0, 1)
|
||||
|
||||
# Assert that derivation is deterministic
|
||||
@ -93,7 +93,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
|
||||
# Needs rescan
|
||||
stop_node(self.nodes[1],1)
|
||||
self.nodes[1] = start_node(1, self.options.tmpdir, ['-usehd=1', '-keypool=0', '-rescan'])
|
||||
self.nodes[1] = start_node(1, self.options.tmpdir, ['-usehd=1', '-keypool=0', '-rescan'], redirect_stderr=True)
|
||||
#connect_nodes_bi(self.nodes, 0, 1)
|
||||
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user