Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_uacomment.py
Show All 21 Lines | def run_test(self): | ||||
assert_equal(test_uacomment[-12:-2], "testnode-0") | assert_equal(test_uacomment[-12:-2], "testnode-0") | ||||
self.restart_node(0, ["-uacomment=foo"]) | self.restart_node(0, ["-uacomment=foo"]) | ||||
foo_uacomment = self.nodes[0].getnetworkinfo()["subversion"][-17:-2] | foo_uacomment = self.nodes[0].getnetworkinfo()["subversion"][-17:-2] | ||||
assert_equal(foo_uacomment, "testnode-0; foo") | assert_equal(foo_uacomment, "testnode-0; foo") | ||||
self.log.info("test -uacomment max length") | self.log.info("test -uacomment max length") | ||||
self.stop_node(0) | self.stop_node(0) | ||||
expected = r"Error: Total length of network version string \([0-9]+\) exceeds maximum length \(256\). Reduce the number or size of uacomments." | expected = ( | ||||
r"Error: Total length of network version string \([0-9]+\) exceeds maximum" | |||||
r" length \(256\). Reduce the number or size of uacomments." | |||||
) | |||||
self.nodes[0].assert_start_raises_init_error( | self.nodes[0].assert_start_raises_init_error( | ||||
[f"-uacomment={'a' * 256}"], expected, match=ErrorMatch.FULL_REGEX) | [f"-uacomment={'a' * 256}"], expected, match=ErrorMatch.FULL_REGEX | ||||
) | |||||
self.log.info("test -uacomment unsafe characters") | self.log.info("test -uacomment unsafe characters") | ||||
for unsafe_char in ['/', ':', '(', ')', '₿', '🏃']: | for unsafe_char in ["/", ":", "(", ")", "₿", "🏃"]: | ||||
expected = r"Error: User Agent comment \(" + re.escape( | expected = ( | ||||
unsafe_char) + r"\) contains unsafe characters." | r"Error: User Agent comment \(" | ||||
+ re.escape(unsafe_char) | |||||
+ r"\) contains unsafe characters." | |||||
) | |||||
self.nodes[0].assert_start_raises_init_error( | self.nodes[0].assert_start_raises_init_error( | ||||
[f"-uacomment={unsafe_char}"], expected, match=ErrorMatch.FULL_REGEX) | [f"-uacomment={unsafe_char}"], expected, match=ErrorMatch.FULL_REGEX | ||||
) | |||||
if __name__ == '__main__': | if __name__ == "__main__": | ||||
UacommentTest().main() | UacommentTest().main() |