Skip to content

Commit 28bac81

Browse files
committed
test: add functional test for getaddrmaninfo
1 parent c8eb8da commit 28bac81

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/functional/rpc_net.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def run_test(self):
6666
self.test_getnodeaddresses()
6767
self.test_addpeeraddress()
6868
self.test_sendmsgtopeer()
69+
self.test_getaddrmaninfo()
6970

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

364+
def test_getaddrmaninfo(self):
365+
self.log.info("Test getaddrmaninfo")
366+
node = self.nodes[1]
367+
368+
self.log.debug("Test that getaddrmaninfo is a hidden RPC")
369+
# It is hidden from general help, but its detailed help may be called directly.
370+
assert "getaddrmaninfo" not in node.help()
371+
assert "getaddrmaninfo" in node.help("getaddrmaninfo")
372+
373+
# current count of ipv4 addresses in addrman is {'new':1, 'tried':1}
374+
self.log.info("Test that count of addresses in addrman match expected values")
375+
res = node.getaddrmaninfo()
376+
assert_equal(res["ipv4"]["new"], 1)
377+
assert_equal(res["ipv4"]["tried"], 1)
378+
assert_equal(res["ipv4"]["total"], 2)
379+
assert_equal(res["all_networks"]["new"], 1)
380+
assert_equal(res["all_networks"]["tried"], 1)
381+
assert_equal(res["all_networks"]["total"], 2)
382+
for net in ["ipv6", "onion", "i2p", "cjdns"]:
383+
assert_equal(res[net]["new"], 0)
384+
assert_equal(res[net]["tried"], 0)
385+
assert_equal(res[net]["total"], 0)
363386

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

0 commit comments

Comments
 (0)