Skip to content

Commit 1e54d61

Browse files
committed
test: add coverage for mapped_as from getrawaddrman
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.
1 parent 8c27149 commit 1e54d61

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/functional/feature_asmap.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import shutil
2828

2929
from test_framework.test_framework import BitcoinTestFramework
30+
from test_framework.util import assert_equal
3031

3132
DEFAULT_ASMAP_FILENAME = 'ip_asn.map' # defined in src/init.cpp
3233
ASMAP = '../../src/test/data/asmap.raw' # path to unit test skeleton asmap
@@ -118,6 +119,14 @@ def test_asmap_health_check(self):
118119
msg = "ASMap Health Check: 4 clearnet peers are mapped to 3 ASNs with 0 peers being unmapped"
119120
with self.node.assert_debug_log(expected_msgs=[msg]):
120121
self.start_node(0, extra_args=['-asmap'])
122+
raw_addrman = self.node.getrawaddrman()
123+
asns = []
124+
for _, entries in raw_addrman.items():
125+
for _, entry in entries.items():
126+
asn = entry['mapped_as']
127+
if asn not in asns:
128+
asns.append(asn)
129+
assert_equal(len(asns), 3)
121130
os.remove(self.default_asmap)
122131

123132
def run_test(self):

0 commit comments

Comments
 (0)