mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01:00
60b3c5a64e
3d0a82cff8cbb809876e82dbe62d14d2adc07d94 devtools: Accomodate block-style copyright blocks (Ben Woosley) 0ef0e51fe4bb592e67255776b5a0ba04679fb8c4 lint: Bump flake8 to 3.7.8 (Ben Woosley) 838920704ad90a71cf288b700052503db8abb17e lint: Disable flake8 W504 warning (Ben Woosley) b21680baf5391a602b295b9d7d0ef66553661cb9 test/contrib: Fix invalid escapes in regex strings (Ben Woosley) Pull request description: This is a second go at #15221, fixing new lints in: W504 line break after binary operator W605 invalid escape sequence F841 local variable 'e' is assigned to but never used This time around: * One commit per rule, for easier review * I went with the PEP-8 style of breaking before binary operators * I looked into the raw regex newline issue, and found that raw strings with newlines embedded do work appropriately. E.g. run `re.match(r" \n ", " \n ")` to check this for yourself. `re.MULTILINE` exists to modify `^` and `$` in multiline scenarios, but all of these searches are per-line. ACKs for top commit: practicalswift: ACK 3d0a82cff8cbb809876e82dbe62d14d2adc07d94 -- diff looks correct Tree-SHA512: bea0c144cadd72e4adf2e9a4b4ee0535dd91a8e694206924cf8a389dc9253f364a717edfe9abda88108fbb67fda19b9e823f46822d7303c0aaa72e48909a6105
41 lines
1.7 KiB
Python
Executable File
41 lines
1.7 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.test_node import ErrorMatch
|
|
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 = r"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, match=ErrorMatch.FULL_REGEX)
|
|
|
|
self.log.info("test -uacomment unsafe characters")
|
|
for unsafe_char in ['/', ':', '(', ')', '₿', '🏃']:
|
|
expected = r"Error: User Agent comment \(" + re.escape(unsafe_char) + r"\) contains unsafe characters."
|
|
self.nodes[0].assert_start_raises_init_error(["-uacomment=" + unsafe_char], expected, match=ErrorMatch.FULL_REGEX)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
UacommentTest().main()
|