Replace the bitcoin-cli -rpcwait
after spawning bitcoind with our own loop that detects when bitcoind exits prematurely (before RPC is up).
This prevents a hang in such a case (see #7463).
Not ready to merge yet. I’ve tested this with a -salvagewallet loop:
0Unexpected exception caught during testing: bitcoind exited with status 1 during initialization
1 File "/data/src/bitcoin/qa/rpc-tests/test_framework/test_framework.py", line 135, in main
2 self.run_test()
3 File "./wallet.py", line 295, in run_test
4 self.nodes = start_nodes(3, self.options.tmpdir, [[m]] * 3)
5 File "/data/src/bitcoin/qa/rpc-tests/test_framework/util.py", line 283, in start_nodes
6 return [ start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]) for i in range(num_nodes) ]
7 File "/data/src/bitcoin/qa/rpc-tests/test_framework/util.py", line 267, in start_node
8 wait_for_bitcoind_start(bitcoind_processes[i], url, i)
9 File "/data/src/bitcoin/qa/rpc-tests/test_framework/util.py", line 144, in wait_for_bitcoind_start
10 raise Exception('bitcoind exited with status %i during initialization' % process.returncode)
11Stopping nodes
Even though reporting is better, it still hangs after “Stopping nodes”, going to investigate why.
wait_bitcoinds
will subsequently wait forever for them to exit (as it uses a global variable to communicate bitcoind_processes).
One-to-last commit makes sure that they’re stopped properly in that case.
Replace the `bitcoin-cli -rpcwait` after spawning bitcoind
with our own loop that detects when bitcoind exits prematurely.
And if one node fails to start, stop the others.
This prevents a hang in such a case (see #7463).
279@@ -267,7 +280,14 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):
280 """
281 if extra_args is None: extra_args = [ None for i in range(num_nodes) ]
282 if binary is None: binary = [ None for i in range(num_nodes) ]
283- return [ start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]) for i in range(num_nodes) ]
284+ rpcs = []
285+ try:
286+ for i in range(num_nodes):
287+ rpcs.append(start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]))
288+ except: # If one node failed to start, stop the others
130@@ -130,11 +131,33 @@ def initialize_datadir(dirname, n):
131 f.write("listenonion=0\n")
132 return datadir
133
134+def rpc_url(i, rpchost=None):
135+ return "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i))
rpcbind_test.py
no longer works after this.