Skip to content

Commit

Permalink
test: add functional test for getaddrmaninfo
Browse files Browse the repository at this point in the history
  • Loading branch information
stratospher committed Sep 19, 2023
1 parent c8eb8da commit 28bac81
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/functional/rpc_net.py
Expand Up @@ -66,6 +66,7 @@ def run_test(self):
self.test_getnodeaddresses()
self.test_addpeeraddress()
self.test_sendmsgtopeer()
self.test_getaddrmaninfo()

def test_connection_count(self):
self.log.info("Test getconnectioncount")
Expand Down Expand Up @@ -360,6 +361,28 @@ def test_sendmsgtopeer(self):
node.sendmsgtopeer(peer_id=0, msg_type="addr", msg=zero_byte_string.hex())
self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0, timeout=10)

def test_getaddrmaninfo(self):
self.log.info("Test getaddrmaninfo")
node = self.nodes[1]

self.log.debug("Test that getaddrmaninfo is a hidden RPC")
# It is hidden from general help, but its detailed help may be called directly.
assert "getaddrmaninfo" not in node.help()
assert "getaddrmaninfo" in node.help("getaddrmaninfo")

# current count of ipv4 addresses in addrman is {'new':1, 'tried':1}
self.log.info("Test that count of addresses in addrman match expected values")
res = node.getaddrmaninfo()
assert_equal(res["ipv4"]["new"], 1)
assert_equal(res["ipv4"]["tried"], 1)
assert_equal(res["ipv4"]["total"], 2)
assert_equal(res["all_networks"]["new"], 1)
assert_equal(res["all_networks"]["tried"], 1)
assert_equal(res["all_networks"]["total"], 2)
for net in ["ipv6", "onion", "i2p", "cjdns"]:
assert_equal(res[net]["new"], 0)
assert_equal(res[net]["tried"], 0)
assert_equal(res[net]["total"], 0)

if __name__ == '__main__':
NetTest().main()

0 comments on commit 28bac81

Please sign in to comment.