Merge #11726: Cleanups + nit fixes for walletdir PR
[bitcoinplatinum.git] / test / functional / uacomment.py
blob0b2c64ab697de9f644656b76fb5154e6e525b094
1 #!/usr/bin/env python3
2 # Copyright (c) 2017 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test the -uacomment option."""
7 from test_framework.test_framework import BitcoinTestFramework
8 from test_framework.util import assert_equal
10 class UacommentTest(BitcoinTestFramework):
11 def set_test_params(self):
12 self.num_nodes = 1
13 self.setup_clean_chain = True
15 def run_test(self):
16 self.log.info("test multiple -uacomment")
17 test_uacomment = self.nodes[0].getnetworkinfo()["subversion"][-12:-1]
18 assert_equal(test_uacomment, "(testnode0)")
20 self.restart_node(0, ["-uacomment=foo"])
21 foo_uacomment = self.nodes[0].getnetworkinfo()["subversion"][-17:-1]
22 assert_equal(foo_uacomment, "(testnode0; foo)")
24 self.log.info("test -uacomment max length")
25 self.stop_node(0)
26 expected = "Total length of network version string (286) exceeds maximum length (256). Reduce the number or size of uacomments."
27 self.assert_start_raises_init_error(0, ["-uacomment=" + 'a' * 256], expected)
29 self.log.info("test -uacomment unsafe characters")
30 for unsafe_char in ['/', ':', '(', ')']:
31 expected = "User Agent comment (" + unsafe_char + ") contains unsafe characters"
32 self.assert_start_raises_init_error(0, ["-uacomment=" + unsafe_char], expected)
34 if __name__ == '__main__':
35 UacommentTest().main()