config: separate the asmap finding and parsing checks

and update the tests.
pull/17812/head
Jon Atack 5 years ago
parent 81c38a2497
commit b8d0412b21
No known key found for this signature in database
GPG Key ID: 4F5721B3D0E3921D

@ -1834,9 +1834,13 @@ bool AppInitMain(NodeContext& node)
if (!asmap_path.is_absolute()) { if (!asmap_path.is_absolute()) {
asmap_path = GetDataDir() / asmap_path; asmap_path = GetDataDir() / asmap_path;
} }
if (!fs::exists(asmap_path)) {
InitError(strprintf(_("Could not find asmap file %s").translated, asmap_path));
return false;
}
std::vector<bool> asmap = CAddrMan::DecodeAsmap(asmap_path); std::vector<bool> asmap = CAddrMan::DecodeAsmap(asmap_path);
if (asmap.size() == 0) { if (asmap.size() == 0) {
InitError(strprintf(_("Could not find or parse specified asmap: '%s'").translated, asmap_path)); InitError(strprintf(_("Could not parse asmap file '%s'").translated, asmap_path));
return false; return false;
} }
const uint256 asmap_version = SerializeHash(asmap); const uint256 asmap_version = SerializeHash(asmap);

@ -75,7 +75,7 @@ class AsmapTest(BitcoinTestFramework):
def test_default_asmap_with_missing_file(self): def test_default_asmap_with_missing_file(self):
self.log.info('Test bitcoind -asmap with missing default map file') self.log.info('Test bitcoind -asmap with missing default map file')
self.stop_node(0) self.stop_node(0)
msg = "Error: Could not find or parse specified asmap: '\"{}\"'".format(self.default_asmap) msg = "Error: Could not find asmap file '\"{}\"'".format(self.default_asmap)
self.node.assert_start_raises_init_error(extra_args=['-asmap'], expected_msg=msg) self.node.assert_start_raises_init_error(extra_args=['-asmap'], expected_msg=msg)
def run_test(self): def run_test(self):

Loading…
Cancel
Save