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 22, 2024
1 parent 8c27149 commit 1e54d61
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 @@ -27,6 +27,7 @@
import shutil

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

DEFAULT_ASMAP_FILENAME = 'ip_asn.map' # defined in src/init.cpp
ASMAP = '../../src/test/data/asmap.raw' # path to unit test skeleton asmap
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 1e54d61

Please sign in to comment.