mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Merge bitcoin/bitcoin#30062: net: add ASMap info in getrawaddrman RPC
1e54d61c46test: add coverage for `mapped_as` from `getrawaddrman` (brunoerg)8c2714907dnet: rpc: return peer's mapped AS in getrawaddrman (brunoerg) Pull request description: This PR adds two new fields in `getrawaddrman` RPC: "mapped_as" and "source_mapped_as". These fields are used to return the ASN (Autonomous System Number) mapped to the peer and its source. With these informations we can have a better view of the bucketing logic with ASMap specially in projects like [addrman-observer](https://github.com/0xb10c/addrman-observer). ACKs for top commit: fjahr: Code review ACK1e54d61c46virtu: ACK [1e54d61](1e54d61c46) 0xB10C: ACK1e54d61c46glozow: ACK1e54d61c46Tree-SHA512: af86bcc7a2e69bebd3fa9eaa2e527e0758c44c0a958de7292514d5f99f8f01f5df3bae11400451268e0255f738ff3acccc77f48fe129937512f1e9d9963c4c5e
This commit is contained in:
@@ -27,6 +27,7 @@ import os
|
||||
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
|
||||
@@ -118,6 +119,14 @@ class AsmapTest(BitcoinTestFramework):
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user