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 after a timeout. Returns the utxo hash of
(self, node_index, *, expected_tip)
| 71 | # Leave them unconnected, we'll use submitblock directly in this test |
| 72 | |
| 73 | def restart_node(self, node_index, *, expected_tip): |
| 74 | """Start up a given node id, wait for the tip to reach the given block hash, and calculate the utxo hash. |
| 75 | |
| 76 | Exceptions during startup or subsequent RPC calls should indicate a node crash (due to -dbcrashratio), in which case we try again. Give up |
| 77 | after a timeout. Returns the utxo hash of the given node.""" |
| 78 | |
| 79 | time_start = time.time() |
| 80 | while time.time() - time_start < 120 * self.options.timeout_factor: |
| 81 | try: |
| 82 | # Any of these RPC calls could throw due to node crash |
| 83 | self.start_node(node_index) |
| 84 | self.nodes[node_index].waitforblock(expected_tip) |
| 85 | utxo_hash = self.nodes[node_index].gettxoutsetinfo()['hash_serialized_3'] |
| 86 | return utxo_hash |
| 87 | except Exception: |
| 88 | # An exception here should mean the node is about to crash. |
| 89 | # If bitcoind exits, then try again. wait_for_node_exit() |
| 90 | # enforces that bitcoind crashed. |
| 91 | self.wait_for_node_exit(node_index, timeout=10) |
| 92 | self.crashed_on_restart += 1 |
| 93 | |
| 94 | # If we got here, bitcoind isn't coming back up on restart. Could be a |
| 95 | # bug in bitcoind, or we've gotten unlucky with our dbcrash ratio -- |
| 96 | # perhaps we generated a test case that blew up our cache? |
| 97 | # If this happens, the test should try to restart without -dbcrashratio |
| 98 | # and make sure that recovery happens. |
| 99 | raise AssertionError(f"Unable to successfully restart node {node_index} in allotted time") |
| 100 | |
| 101 | def submit_block_catch_error(self, node_index, block): |
| 102 | """Try submitting a block to the given node. |