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 May 15, 2023
1 parent 332cf61 commit 7d7ee5e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/functional/rpc_net.py
Expand Up @@ -65,6 +65,7 @@ def run_test(self):
self.test_service_flags()
self.test_getnodeaddresses()
self.test_addpeeraddress()
self.test_getaddrmaninfo()

def test_connection_count(self):
self.log.info("Test getconnectioncount")
Expand Down Expand Up @@ -328,6 +329,23 @@ def test_addpeeraddress(self):
addrs = node.getnodeaddresses(count=0) # getnodeaddresses re-runs the addrman checks
assert_equal(len(addrs), 2)

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}
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)

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

0 comments on commit 7d7ee5e

Please sign in to comment.