mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
1948435b4a
aac6bce112
test: Make ua_comment test pass on 0.16.0 (Wladimir J. van der Laan)
Pull request description:
The specific length of the uacomment is one shorter on `0.16.0` than on `0.15.99` causing the (stupid) test to fail.
This change makes `assert_start_raises_init_error` optionally take a regexp, so that the error message can be checked without being specific about the reported length.
Tree-SHA512: 1c5e9f1d0b36f004f8113c7e211e8281194ce8057869ac3702172d8b021df3c3aa3b8f79b9434678ed0fb7146f848802410647d434fc884aa200b6a5e26afe8b
36 lines
1.5 KiB
Python
Executable File
36 lines
1.5 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."""
|
|
|
|
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 = "exceeds maximum length (256). Reduce the number or size of uacomments."
|
|
self.assert_start_raises_init_error(0, ["-uacomment=" + 'a' * 256], expected)
|
|
|
|
self.log.info("test -uacomment unsafe characters")
|
|
for unsafe_char in ['/', ':', '(', ')']:
|
|
expected = "User Agent comment (" + unsafe_char + ") contains unsafe characters"
|
|
self.assert_start_raises_init_error(0, ["-uacomment=" + unsafe_char], expected)
|
|
|
|
if __name__ == '__main__':
|
|
UacommentTest().main()
|