test: Fix feature_dbcrash.py --usecli intermittent error

Catch any Exception in verify_utxo_hash and let restart_node verify the
crash via wait_for_node_exit.

(Also, use named args in restart_node, while touching this test)

Catching any Exception covers possible subprocess.CalledProcessError
that may happen in a --usecli run. E.g.

  TestFramework (INFO): Verifying utxo hash matches for all nodes
  TestFramework.bitcoincli (DEBUG): Running bitcoin-cli ['-datadir=/tmp/bitcoin_func_test_gzufs0ht/node0', '-rpcclienttimeout=240', '-rpcconnect=127.0.0.1', '-rpcport=20963', 'gettxoutsetinfo']
  TestFramework.bitcoincli (DEBUG): Running bitcoin-cli ['-datadir=/tmp/bitcoin_func_test_gzufs0ht/node1', '-rpcclienttimeout=240', '-rpcconnect=127.0.0.1', '-rpcport=20964', 'gettxoutsetinfo']
  TestFramework (ERROR): Called Process failed with stdout='error: timeout on transient error: Could not connect to the server 127.0.0.1:20964 (error code 1 - "EOF reached")

  Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
  Use "bitcoin-cli -help" for more info.
  '; stderr='None';
  Traceback (most recent call last):
    File "./test/functional/test_framework/test_framework.py", line 143, in main
      self.run_test()
      ~~~~~~~~~~~~~^^
    File "./test/functional/feature_dbcrash.py", line 273, in run_test
      self.verify_utxo_hash()
      ~~~~~~~~~~~~~~~~~~~~~^^
    File "./test/functional/feature_dbcrash.py", line 182, in verify_utxo_hash
      nodei_utxo_hash = self.nodes[i].gettxoutsetinfo()['hash_serialized_3']
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
    File "./test/functional/test_framework/test_node.py", line 963, in __call__
      return self.cli.send_cli(self.command, *args, **kwargs)
             ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "./test/functional/test_framework/test_node.py", line 1043, in send_cli
      raise subprocess.CalledProcessError(returncode, p_args, output=cli_stderr)
This commit is contained in:
MarcoFalke
2026-05-26 12:04:31 +02:00
parent fa09de8b68
commit fac27d702f

View File

@@ -70,7 +70,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
self.start_nodes()
# Leave them unconnected, we'll use submitblock directly in this test
def restart_node(self, node_index, expected_tip):
def restart_node(self, node_index, *, expected_tip):
"""Start up a given node id, wait for the tip to reach the given block hash, and calculate the utxo hash.
Exceptions during startup or subsequent RPC calls should indicate a node crash (due to -dbcrashratio), in which case we try again. Give up
@@ -139,7 +139,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
# wait_for_node_exit() enforces that bitcoind crashed.
self.wait_for_node_exit(i, timeout=30)
self.log.debug(f"Restarting node {i} after block hash {block_hash}")
nodei_utxo_hash = self.restart_node(i, block_hash)
nodei_utxo_hash = self.restart_node(i, expected_tip=block_hash)
assert nodei_utxo_hash is not None
self.restart_counts[i] += 1
else:
@@ -168,9 +168,9 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
for i in range(3):
try:
nodei_utxo_hash = self.nodes[i].gettxoutsetinfo()['hash_serialized_3']
except OSError:
except Exception:
# probably a crash on db flushing
nodei_utxo_hash = self.restart_node(i, self.nodes[3].getbestblockhash())
nodei_utxo_hash = self.restart_node(i, expected_tip=self.nodes[3].getbestblockhash())
assert_equal(nodei_utxo_hash, node3_utxo_hash)
def generate_small_transactions(self, node, count, utxo_list):