Skip to content

Commit

Permalink
test: add coverage for mapped_as from getrawaddrman
Browse files Browse the repository at this point in the history
Test addresses are being mapped according to the ASMap
file provided properly. Compare the result of the `getrawaddrman`
RPC with the result from the ASMap Health Check.
  • Loading branch information
brunoerg committed May 7, 2024
1 parent 3733f6b commit f80c47c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/functional/feature_asmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import os
import shutil

from test_framework.util import assert_equal
from test_framework.test_framework import BitcoinTestFramework

DEFAULT_ASMAP_FILENAME = 'ip_asn.map' # defined in src/init.cpp
Expand Down Expand Up @@ -118,6 +119,14 @@ def test_asmap_health_check(self):
msg = "ASMap Health Check: 4 clearnet peers are mapped to 3 ASNs with 0 peers being unmapped"
with self.node.assert_debug_log(expected_msgs=[msg]):
self.start_node(0, extra_args=['-asmap'])
raw_addrman = self.node.getrawaddrman()
asns = []
for _, entries in raw_addrman.items():
for _, entry in entries.items():
asn = entry['mapped_as']
if asn not in asns:
asns.append(asn)
assert_equal(len(asns), 3)
os.remove(self.default_asmap)

def run_test(self):
Expand Down

0 comments on commit f80c47c

Please sign in to comment.