mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
7a880f29df
fae1374
qa: Allow for partial_match when checking init error (MarcoFalke)5812273
[Tests] Require exact match in assert_start_raises_init_eror() (John Newbery)0ec08a6
[Tests] Move assert_start_raises_init_error method to TestNode (John Newbery) Pull request description: Extracted from #12379, because the changes are important on their own. This allows for exact testing, since the match can be specified with a strict regex. Internal details (such as exact formatting of the error message) can still be fuzzed away by regex wildcards. Tree-SHA512: 605d2c9c42362a32d42321b066637577a026d0bb8cfc1c9f5737a4ca6503ffe85457a5122cea6e1101053ccc6c8aa1bbae3602e1fa7d2988bf7d5c275f412f66 Signed-off-by: pasta <pasta@dashboost.org>
40 lines
1.6 KiB
Python
Executable File
40 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2017 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test the -uacomment option."""
|
|
|
|
import re
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import assert_equal
|
|
|
|
|
|
class UacommentTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 1
|
|
self.setup_clean_chain = True
|
|
|
|
def run_test(self):
|
|
self.log.info("test multiple -uacomment")
|
|
test_uacomment = self.nodes[0].getnetworkinfo()["subversion"][-12:-1]
|
|
assert_equal(test_uacomment, "(testnode0)")
|
|
|
|
self.restart_node(0, ["-uacomment=foo"])
|
|
foo_uacomment = self.nodes[0].getnetworkinfo()["subversion"][-17:-1]
|
|
assert_equal(foo_uacomment, "(testnode0; foo)")
|
|
|
|
self.log.info("test -uacomment max length")
|
|
self.stop_node(0)
|
|
expected = "Error: Total length of network version string \([0-9]+\) exceeds maximum length \(256\). Reduce the number or size of uacomments."
|
|
self.nodes[0].assert_start_raises_init_error(["-uacomment=" + 'a' * 256], expected)
|
|
|
|
self.log.info("test -uacomment unsafe characters")
|
|
for unsafe_char in ['/', ':', '(', ')']:
|
|
expected = "Error: User Agent comment \(" + re.escape(unsafe_char) + "\) contains unsafe characters."
|
|
self.nodes[0].assert_start_raises_init_error(["-uacomment=" + unsafe_char], expected)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
UacommentTest().main()
|