mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-18 19:47:53 +02:00
[tests] Allow stderr to be tested against specified string
Allow bitcoind's stderr to be tested against a specified string on shutdown.
This commit is contained in:
@@ -289,9 +289,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
for node in self.nodes:
|
||||
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
|
||||
|
||||
def stop_node(self, i):
|
||||
def stop_node(self, i, expected_stderr=''):
|
||||
"""Stop a bitcoind test node"""
|
||||
self.nodes[i].stop_node()
|
||||
self.nodes[i].stop_node(expected_stderr)
|
||||
self.nodes[i].wait_until_stopped()
|
||||
|
||||
def stop_nodes(self):
|
||||
|
||||
@@ -188,7 +188,7 @@ class TestNode():
|
||||
wallet_path = "wallet/%s" % wallet_name
|
||||
return self.rpc / wallet_path
|
||||
|
||||
def stop_node(self):
|
||||
def stop_node(self, expected_stderr=''):
|
||||
"""Stop the node."""
|
||||
if not self.running:
|
||||
return
|
||||
@@ -197,6 +197,13 @@ class TestNode():
|
||||
self.stop()
|
||||
except http.client.CannotSendRequest:
|
||||
self.log.exception("Unable to stop node.")
|
||||
|
||||
# Check that stderr is as expected
|
||||
self.stderr.seek(0)
|
||||
stderr = self.stderr.read().decode('utf-8').strip()
|
||||
if stderr != expected_stderr:
|
||||
raise AssertionError("Unexpected stderr {} != {}".format(stderr, expected_stderr))
|
||||
|
||||
del self.p2ps[:]
|
||||
|
||||
def is_node_stopped(self):
|
||||
|
||||
Reference in New Issue
Block a user