From 6e8e7f433fc3f753a20833aebe54692cdfe5ed75 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Thu, 19 Dec 2024 13:24:48 -0500 Subject: [PATCH] Fix nonsensical -noasmap behavior Instead of failing with "fread failed: iostream error" error when -noasmap is specified, just don't load an asmap file. --- src/init.cpp | 2 +- test/functional/feature_asmap.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 771efc64918..9273f40bb09 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1433,7 +1433,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // Read asmap file if configured std::vector asmap; - if (args.IsArgSet("-asmap")) { + if (args.IsArgSet("-asmap") && !args.IsArgNegated("-asmap")) { fs::path asmap_path = args.GetPathArg("-asmap", DEFAULT_ASMAP_FILENAME); if (!asmap_path.is_absolute()) { asmap_path = args.GetDataDirNet() / asmap_path; diff --git a/test/functional/feature_asmap.py b/test/functional/feature_asmap.py index 53e94bf4dfb..7f0103ece3b 100755 --- a/test/functional/feature_asmap.py +++ b/test/functional/feature_asmap.py @@ -54,6 +54,12 @@ class AsmapTest(BitcoinTestFramework): with self.node.assert_debug_log(['Using /16 prefix for IP bucketing']): self.start_node(0) + def test_noasmap_arg(self): + self.log.info('Test bitcoind with -noasmap arg passed') + self.stop_node(0) + with self.node.assert_debug_log(['Using /16 prefix for IP bucketing']): + self.start_node(0, ["-noasmap"]) + def test_asmap_with_absolute_path(self): self.log.info('Test bitcoind -asmap=') self.stop_node(0) @@ -137,6 +143,7 @@ class AsmapTest(BitcoinTestFramework): self.asmap_raw = os.path.join(base_dir, ASMAP) self.test_without_asmap_arg() + self.test_noasmap_arg() self.test_asmap_with_absolute_path() self.test_asmap_with_relative_path() self.test_default_asmap()