mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-28 16:36:04 +01:00
on startup, write config options to debug.log
This commit is contained in:
@@ -83,10 +83,40 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||
self.start_node(0, extra_args=['-noconnect=0'])
|
||||
self.stop_node(0)
|
||||
|
||||
def test_args_log(self):
|
||||
self.log.info('Test config args logging')
|
||||
with self.nodes[0].assert_debug_log(
|
||||
expected_msgs=[
|
||||
'Command-line arg: addnode="some.node"',
|
||||
'Command-line arg: rpcauth=****',
|
||||
'Command-line arg: rpcbind=****',
|
||||
'Command-line arg: rpcpassword=****',
|
||||
'Command-line arg: rpcuser=****',
|
||||
'Command-line arg: torpassword=****',
|
||||
'Config file arg: regtest="1"',
|
||||
'Config file arg: [regtest] server="1"',
|
||||
],
|
||||
unexpected_msgs=[
|
||||
'alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0',
|
||||
'127.1.1.1',
|
||||
'secret-rpcuser',
|
||||
'secret-torpassword',
|
||||
]):
|
||||
self.start_node(0, extra_args=[
|
||||
'-addnode=some.node',
|
||||
'-rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0',
|
||||
'-rpcbind=127.1.1.1',
|
||||
'-rpcpassword=',
|
||||
'-rpcuser=secret-rpcuser',
|
||||
'-torpassword=secret-torpassword',
|
||||
])
|
||||
self.stop_node(0)
|
||||
|
||||
def run_test(self):
|
||||
self.stop_node(0)
|
||||
|
||||
self.test_log_buffer()
|
||||
self.test_args_log()
|
||||
|
||||
self.test_config_file_parser()
|
||||
|
||||
|
||||
@@ -298,7 +298,9 @@ class TestNode():
|
||||
wait_until(self.is_node_stopped, timeout=timeout)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def assert_debug_log(self, expected_msgs, timeout=2):
|
||||
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
|
||||
if unexpected_msgs is None:
|
||||
unexpected_msgs = []
|
||||
time_end = time.time() + timeout
|
||||
debug_log = os.path.join(self.datadir, self.chain, 'debug.log')
|
||||
with open(debug_log, encoding='utf-8') as dl:
|
||||
@@ -313,6 +315,9 @@ class TestNode():
|
||||
dl.seek(prev_size)
|
||||
log = dl.read()
|
||||
print_log = " - " + "\n - ".join(log.splitlines())
|
||||
for unexpected_msg in unexpected_msgs:
|
||||
if re.search(re.escape(unexpected_msg), log, flags=re.MULTILINE):
|
||||
self._raise_assertion_error('Unexpected message "{}" partially matches log:\n\n{}\n\n'.format(unexpected_msg, print_log))
|
||||
for expected_msg in expected_msgs:
|
||||
if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
|
||||
found = False
|
||||
|
||||
Reference in New Issue
Block a user