|
30 | 30 |
|
31 | 31 | BITCOIND_PROC_WAIT_TIMEOUT = 60
|
32 | 32 |
|
| 33 | + |
| 34 | +class FailedToStartError(Exception): |
| 35 | + """Raised when a node fails to start correctly.""" |
| 36 | + |
| 37 | + |
33 | 38 | class TestNode():
|
34 | 39 | """A class for representing a bitcoind node under test.
|
35 | 40 |
|
@@ -102,7 +107,8 @@ def wait_for_rpc_connection(self):
|
102 | 107 | # Poll at a rate of four times per second
|
103 | 108 | poll_per_s = 4
|
104 | 109 | for _ in range(poll_per_s * self.rpc_timeout):
|
105 |
| - assert self.process.poll() is None, "bitcoind exited with status %i during initialization" % self.process.returncode |
| 110 | + if self.process.poll() is not None: |
| 111 | + raise FailedToStartError('bitcoind exited with status {} during initialization'.format(self.process.returncode)) |
106 | 112 | try:
|
107 | 113 | self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
|
108 | 114 | self.rpc.getblockcount()
|
@@ -179,9 +185,9 @@ def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, par
|
179 | 185 | self.start(extra_args, stderr=log_stderr, *args, **kwargs)
|
180 | 186 | self.wait_for_rpc_connection()
|
181 | 187 | self.stop_node()
|
182 |
| - self.wait_util_stopped() |
183 |
| - except Exception as e: |
184 |
| - assert 'bitcoind exited' in str(e) # node must have shutdown |
| 188 | + self.wait_until_stopped() |
| 189 | + except FailedToStartError as e: |
| 190 | + self.log.debug('bitcoind failed to start: %s', e) |
185 | 191 | self.running = False
|
186 | 192 | self.process = None
|
187 | 193 | # Check stderr for expected message
|
|
0 commit comments