Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/devtools/clang-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main():
filename = None
lines_by_file = {}
for line in sys.stdin:
match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
if match:
filename = match.group(2)
if filename is None:
Expand All @@ -119,7 +119,7 @@ def main():
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
continue

match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
if match:
start_line = int(match.group(1))
line_count = 1
Expand Down
73 changes: 36 additions & 37 deletions contrib/devtools/copyright_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_filenames_to_examine(base_directory):
################################################################################


COPYRIGHT_WITH_C = 'Copyright \(c\)'
COPYRIGHT_WITH_C = r'Copyright \(c\)'
COPYRIGHT_WITHOUT_C = 'Copyright'
ANY_COPYRIGHT_STYLE = '(%s|%s)' % (COPYRIGHT_WITH_C, COPYRIGHT_WITHOUT_C)

Expand All @@ -88,43 +88,42 @@ def get_filenames_to_examine(base_directory):
ANY_COPYRIGHT_COMPILED = re.compile(ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE)

def compile_copyright_regex(copyright_style, year_style, name):
return re.compile('%s %s,? %s' % (copyright_style, year_style, name))
return re.compile('%s %s,? %s\n' % (copyright_style, year_style, name))

EXPECTED_HOLDER_NAMES = [
"Satoshi Nakamoto\n",
"The Bitcoin Core developers\n",
"The Bitcoin Core developers \n",
"Bitcoin Core Developers\n",
"the Bitcoin Core developers\n",
"The Bitcoin developers\n",
"The LevelDB Authors\. All rights reserved\.\n",
"BitPay Inc\.\n",
"BitPay, Inc\.\n",
"University of Illinois at Urbana-Champaign\.\n",
"MarcoFalke\n",
"Pieter Wuille\n",
"Pieter Wuille +\*\n",
"Pieter Wuille, Gregory Maxwell +\*\n",
"Pieter Wuille, Andrew Poelstra +\*\n",
"Ian Miers, Christina Garman and Matthew Green\n",
"Andrew Poelstra +\*\n",
"Wladimir J. van der Laan\n",
"Jeff Garzik\n",
"Diederik Huys, Pieter Wuille +\*\n",
"Thomas Daede, Cory Fields +\*\n",
"Jan-Klaas Kollhof\n",
"Sam Rushing\n",
"ArtForz -- public domain half-a-node\n",
" Projet RNRT SAPHIR\n",
"The Zcash developers\n",
"The Dash developers\n",
"The Dash Developers\n",
"The Dash Core developers\n",
"The PIVX developers\n",
"The PPCoin developers\n",
"The NovaCoin Developers",
"The BlackCoin Developers\n",
"The Blackcoin More developers\n",
r"Satoshi Nakamoto",
r"The Bitcoin Core developers",
r"Bitcoin Core Developers",
r"the Bitcoin Core developers",
r"The Bitcoin developers",
r"The LevelDB Authors\. All rights reserved\.",
r"BitPay Inc\.",
r"BitPay, Inc\.",
r"University of Illinois at Urbana-Champaign\.",
r"MarcoFalke",
r"Pieter Wuille",
r"Pieter Wuille +\*",
r"Pieter Wuille, Gregory Maxwell +\*",
r"Pieter Wuille, Andrew Poelstra +\*",
r"Ian Miers, Christina Garman and Matthew Green",
r"Andrew Poelstra +\*",
r"Wladimir J. van der Laan",
r"Jeff Garzik",
r"Diederik Huys, Pieter Wuille +\*",
r"Thomas Daede, Cory Fields +\*",
r"Jan-Klaas Kollhof",
r"Sam Rushing",
r"ArtForz -- public domain half-a-node",
r" Projet RNRT SAPHIR",
r"The Zcash developers",
r"The Dash developers",
r"The Dash Developers",
r"The Dash Core developers",
r"The PIVX developers",
r"The PPCoin developers",
r"The NovaCoin Developers",
r"The BlackCoin Developers",
r"The Blackcoin More developers",
]

DOMINANT_STYLE_COMPILED = {}
Expand Down Expand Up @@ -354,7 +353,7 @@ def write_file_lines(filename, file_lines):
# update header years execution
################################################################################

COPYRIGHT = 'Copyright \(c\)'
COPYRIGHT = r'Copyright \(c\)'
YEAR = "20[0-9][0-9]"
YEAR_RANGE = '(%s)(-%s)?' % (YEAR, YEAR)
HOLDER = 'The PIVX developers'
Expand Down
4 changes: 1 addition & 3 deletions contrib/devtools/symbol-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def read_libraries(filename):
for line in stdout.splitlines():
tokens = line.split()
if len(tokens)>2 and tokens[1] == '(NEEDED)':
match = re.match('^Shared library: \[(.*)\]$', ' '.join(tokens[2:]))
match = re.match(r'^Shared library: \[(.*)\]$', ' '.join(tokens[2:]))
if match:
libraries.append(match.group(1))
else:
Expand Down Expand Up @@ -172,5 +172,3 @@ def read_libraries(filename):
retval = 1

sys.exit(retval)


2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ bool AppInitParameterInteraction()
// ********************************************************* Step 2: parameter interactions

if (!fs::is_directory(GetBlocksDir())) {
return UIError(strprintf(_("Specified blocks directory \"%s\" does not exist.\n"), gArgs.GetArg("-blocksdir", "").c_str()));
return UIError(strprintf(_("Specified blocks directory \"%s\" does not exist."), gArgs.GetArg("-blocksdir", "").c_str()));
}

// Make sure enough file descriptors are available
Expand Down
11 changes: 10 additions & 1 deletion test/functional/combine_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import argparse
from collections import defaultdict, namedtuple
import glob
import heapq
import itertools
import os
Expand Down Expand Up @@ -66,9 +67,17 @@ def read_logs(tmp_dir):
Delegates to generator function get_log_events() to provide individual log events
for each of the input log files."""

# Find out what the folder is called that holds the debug.log file
chain = glob.glob("{}/node0/*/debug.log".format(tmp_dir))
if chain:
chain = chain[0] # pick the first one if more than one chain was found (should never happen)
chain = re.search(r'node0/(.+?)/debug\.log$', chain).group(1) # extract the chain name
else:
chain = 'regtest' # fallback to regtest (should only happen when none exists)

files = [("test", "%s/test_framework.log" % tmp_dir)]
for i in itertools.count():
logfile = "{}/node{}/regtest/debug.log".format(tmp_dir, i)
logfile = "{}/node{}/{}/debug.log".format(tmp_dir, i, chain)
if not os.path.isfile(logfile):
break
files.append(("node%d" % i, logfile))
Expand Down
6 changes: 3 additions & 3 deletions test/functional/feature_abortnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Copyright (c) 2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php.
"""Test bitcoind aborts if can't disconnect a block.
"""Test pivxd aborts if can't disconnect a block.

- Start a single node and generate 3 blocks.
- Delete the undo data.
- Mine a fork that requires disconnecting the tip.
- Verify that bitcoind AbortNode's.
- Verify that pivxd AbortNode's.
"""

import os
Expand Down Expand Up @@ -44,7 +44,7 @@ def run_test(self):
self.log.info("Waiting for crash")
wait_until(lambda: self.nodes[0].is_node_stopped(), timeout=60)
self.log.info("Node crashed - now verifying restart fails")
self.assert_start_raises_init_error(0)
self.nodes[0].assert_start_raises_init_error()

if __name__ == '__main__':
AbortNodeTest().main()
4 changes: 2 additions & 2 deletions test/functional/feature_asmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def test_default_asmap_with_missing_file(self):
self.log.info('Test pivxd -asmap with missing default map file')
self.stop_node(0)
msg = "Error: Could not find asmap file \"{}\"".format(self.default_asmap)
self.assert_start_raises_init_error(0, extra_args=['-asmap'], expected_msg=msg)
self.nodes[0].assert_start_raises_init_error(extra_args=['-asmap'], expected_msg=msg)

def test_empty_asmap(self):
self.log.info('Test pivxd -asmap with empty map file')
self.stop_node(0)
with open(self.default_asmap, "w", encoding="utf-8") as f:
f.write("")
msg = "Error: Could not parse asmap file \"{}\"".format(self.default_asmap)
self.assert_start_raises_init_error(0, extra_args=['-asmap'], expected_msg=msg)
self.nodes[0].assert_start_raises_init_error(extra_args=['-asmap'], expected_msg=msg)
os.remove(self.default_asmap)

def run_test(self):
Expand Down
8 changes: 5 additions & 3 deletions test/functional/feature_blocksdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ def run_test(self):
shutil.rmtree(self.nodes[0].datadir)
initialize_datadir(self.options.tmpdir, 0)
self.log.info("Starting with nonexistent blocksdir ...")
self.assert_start_raises_init_error(0, ["-blocksdir="+self.options.tmpdir+ "/blocksdir"], "Specified blocks director")
os.mkdir(self.options.tmpdir+ "/blocksdir")
blocksdir_path = os.path.join(self.options.tmpdir, 'blocksdir')
expected_err = 'Error: Specified blocks directory "{}" does not exist.'.format(blocksdir_path)
self.nodes[0].assert_start_raises_init_error(["-blocksdir=" + blocksdir_path], expected_err)
os.mkdir(blocksdir_path)
self.log.info("Starting with existing blocksdir ...")
self.start_node(0, ["-blocksdir="+self.options.tmpdir+ "/blocksdir"])
self.start_node(0, ["-blocksdir=" + blocksdir_path])
self.log.info("mining blocks..")
self.nodes[0].generate(10)
assert(os.path.isfile(os.path.join(self.options.tmpdir, "blocksdir", "regtest", "blocks", "blk00000.dat")))
Expand Down
5 changes: 2 additions & 3 deletions test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run_test(self):

# Check that using -datadir argument on non-existent directory fails
self.nodes[0].datadir = new_data_dir
self.assert_start_raises_init_error(0, ['-datadir='+new_data_dir], 'Error: Specified data directory "' + new_data_dir + '" does not exist.')
self.nodes[0].assert_start_raises_init_error(['-datadir=' + new_data_dir], 'Error: Specified data directory "' + new_data_dir + '" does not exist.')

# Check that using non-existent datadir in conf file fails
conf_file = os.path.join(default_data_dir, "pivx.conf")
Expand All @@ -37,8 +37,7 @@ def run_test(self):
f.write("datadir=" + new_data_dir + "\n")
f.write(conf_file_contents)

# Temporarily disabled, because this test would access the user's home dir (~/.pivx)
#self.assert_start_raises_init_error(0, ['-conf=' + conf_file], 'Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.')
self.nodes[0].assert_start_raises_init_error(['-conf=' + conf_file], 'Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.')

# Create the directory and ensure the config file now works
os.mkdir(new_data_dir)
Expand Down
8 changes: 4 additions & 4 deletions test/functional/feature_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os

from test_framework.test_framework import PivxTestFramework
from test_framework.test_node import ErrorMatch


class LoggingTest(PivxTestFramework):
Expand Down Expand Up @@ -35,8 +36,8 @@ def run_test(self):
invdir = os.path.join(self.nodes[0].datadir, "regtest", "foo")
invalidname = os.path.join("foo", "foo.log")
self.stop_node(0)
self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % (invalidname)],
"Error: Could not open debug log file")
exp_stderr = r"Error: Could not open debug log file \S+$"
self.nodes[0].assert_start_raises_init_error(["-debuglogfile=%s" % (invalidname)], exp_stderr, match=ErrorMatch.FULL_REGEX)
assert not os.path.isfile(os.path.join(invdir, "foo.log"))
self.log.info("Invalid relative filename throws")

Expand All @@ -50,8 +51,7 @@ def run_test(self):
self.stop_node(0)
invdir = os.path.join(self.options.tmpdir, "foo")
invalidname = os.path.join(invdir, "foo.log")
self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % invalidname],
"Error: Could not open debug log file")
self.nodes[0].assert_start_raises_init_error(["-debuglogfile=%s" % invalidname], exp_stderr, match=ErrorMatch.FULL_REGEX)
assert not os.path.isfile(os.path.join(invdir, "foo.log"))
self.log.info("Invalid absolute filename throws")

Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def run_test(self):
self.nodes[1].generate(51)
self.sync_all()

# Give bitcoind 10 seconds to write the alert notification
# Give pivxd 10 seconds to write the alert notification
wait_until(lambda: len(os.listdir(self.alertnotify_dir)), timeout=10)

for notify_file in os.listdir(self.alertnotify_dir):
Expand Down
6 changes: 3 additions & 3 deletions test/functional/feature_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2015-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 bitcoind with different proxy configuration.
"""Test pivxd with different proxy configuration.

Test plan:
- Start pivxd's with different proxy configurations
Expand Down Expand Up @@ -96,7 +96,7 @@ def node_test(self, node, proxies, auth, test_onion=True):
node.addnode("15.61.23.23:1234", "onetry")
cmd = proxies[0].queue.get()
assert(isinstance(cmd, Socks5Command))
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
# Note: pivxd's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
assert_equal(cmd.addr, b"15.61.23.23")
assert_equal(cmd.port, 1234)
Expand All @@ -110,7 +110,7 @@ def node_test(self, node, proxies, auth, test_onion=True):
node.addnode("[1233:3432:2434:2343:3234:2345:6546:4534]:5443", "onetry")
cmd = proxies[1].queue.get()
assert(isinstance(cmd, Socks5Command))
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
# Note: pivxd's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
assert_equal(cmd.addr, b"1233:3432:2434:2343:3234:2345:6546:4534")
assert_equal(cmd.port, 5443)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2014-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 running bitcoind with -reindex and -reindex-chainstate options.
"""Test running pivxd with -reindex and -reindex-chainstate options.

- Start a single node and generate 3 blocks.
- Stop the node and restart it with -reindex. Verify that the node has reindexed up to block 3.
Expand Down
12 changes: 8 additions & 4 deletions test/functional/feature_uacomment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the -uacomment option."""

import re

from test_framework.test_framework import PivxTestFramework
from test_framework.test_node import ErrorMatch
from test_framework.util import assert_equal

class UacommentTest(PivxTestFramework):
Expand All @@ -23,13 +26,14 @@ def run_test(self):

self.log.info("test -uacomment max length")
self.stop_node(0)
expected = "exceeds maximum length (256). Reduce the number or size of -uacomment."
self.assert_start_raises_init_error(0, ["-uacomment=" + 'a' * 256], expected)
expected = r"Error: Total length of network version string \([0-9]+\) exceeds maximum length \(256\). Reduce the number or size of -uacomment."
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 = "User Agent comment (" + unsafe_char + ") contains unsafe characters"
self.assert_start_raises_init_error(0, ["-uacomment=" + unsafe_char], expected)
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()
4 changes: 2 additions & 2 deletions test/functional/mempool_persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# file COPYING or https://www.opensource.org/licenses/mit-license.php.
"""Test mempool persistence.

By default, bitcoind will dump mempool on shutdown and
By default, pivxd will dump mempool on shutdown and
then reload it on startup. This can be overridden with
the -persistmempool=false command line option.

Expand Down Expand Up @@ -106,7 +106,7 @@ def run_test(self):
assert self.nodes[0].getmempoolinfo()["loaded"]
assert_equal(len(self.nodes[1].getrawmempool()), 5)

self.log.debug("Prevent bitcoind from writing mempool.dat to disk. Verify that `savemempool` fails")
self.log.debug("Prevent pivxd from writing mempool.dat to disk. Verify that `savemempool` fails")
# to test the exception we are creating a tmp folder called mempool.dat.new
# which is an implementation detail that could change and break this test
mempooldotnew1 = mempooldat1 + '.new'
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_leak.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
This test connects to a node and sends it a few messages, trying to intice it
into sending us something it shouldn't.

Also test that nodes that send unsupported service bits to bitcoind are disconnected
Also test that nodes that send unsupported service bits to pivxd are disconnected
and don't receive a VERACK. Unsupported service bits are currently 1 << 5 and
1 << 7 (until August 1st 2018).
"""
Expand Down Expand Up @@ -64,7 +64,7 @@ def on_blocktxn(self, message): self.bad_message(message)
# anyway, and eventually get disconnected.
class CNodeNoVersionBan(CLazyNode):
# send a bunch of veracks without sending a message. This should get us disconnected.
# NOTE: implementation-specific check here. Remove if bitcoind ban behavior changes
# NOTE: implementation-specific check here. Remove if pivxd ban behavior changes
def on_open(self):
super().on_open()
for i in range(banscore):
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2014-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 running bitcoind with the -rpcbind and -rpcallowip options."""
"""Test running pivxd with the -rpcbind and -rpcallowip options."""

import socket
import sys
Expand Down
Loading