Skip to content

Commit

Permalink
Merge bitcoin#17812: enable passing -asmap an absolute file path
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Mar 18, 2021
1 parent a199678 commit 5868788
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageGroup(_("Connection options:"));
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info). This option can be specified multiple times to add multiple nodes."));
strUsage += HelpMessageOpt("-allowprivatenet", strprintf(_("Allow RFC1918 addresses to be relayed and connected to (default: %u)"), DEFAULT_ALLOWPRIVATENET));
strUsage += HelpMessageOpt("-asmap=<file>", strprintf(_("Specify asn mapping used for bucketing of the peers (default: %s). Path should be relative to the -datadir path."), DEFAULT_ASMAP_FILENAME));
strUsage += HelpMessageOpt("-asmap=<file>", strprintf(_("Specify asn mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location."), DEFAULT_ASMAP_FILENAME));
strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
strUsage += HelpMessageOpt("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME));
strUsage += HelpMessageOpt("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
Expand Down
18 changes: 15 additions & 3 deletions test/functional/feature_asmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
1. `dashd` with no -asmap arg, using /16 prefix for IP bucketing
2. `dashd -asmap=<relative path>`, using the unit test skeleton asmap
2. `dashd -asmap=<absolute path>`, using the unit test skeleton asmap
3. `dashd -asmap/-asmap=` with no file specified, using the default asmap
3. `dashd -asmap=<relative path>`, using the unit test skeleton asmap
4. `dashd -asmap` with no file specified, and a missing default asmap file
4. `dashd -asmap/-asmap=` with no file specified, using the default asmap
5. `dashd -asmap` with no file specified and a missing default asmap file
The tests are order-independent. The slowest test (missing default asmap file)
is placed last.
Expand Down Expand Up @@ -42,6 +44,15 @@ def test_without_asmap_arg(self):
with self.node.assert_debug_log(['Using /16 prefix for IP bucketing']):
self.start_node(0)

def test_asmap_with_absolute_path(self):
self.log.info('Test dashd -asmap=<absolute path>')
self.stop_node(0)
filename = os.path.join(self.datadir, 'my-map-file.map')
shutil.copyfile(self.asmap_raw, filename)
with self.node.assert_debug_log(expected_messages(filename)):
self.start_node(0, ['-asmap={}'.format(filename)])
os.remove(filename)

def test_asmap_with_relative_path(self):
self.log.info('Test dashd -asmap=<relative path>')
self.stop_node(0)
Expand Down Expand Up @@ -74,6 +85,7 @@ def run_test(self):
self.asmap_raw = os.path.join(os.path.dirname(os.path.realpath(__file__)), ASMAP)

self.test_without_asmap_arg()
self.test_asmap_with_absolute_path()
self.test_asmap_with_relative_path()
self.test_default_asmap()
self.test_default_asmap_with_missing_file()
Expand Down

0 comments on commit 5868788

Please sign in to comment.