aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorstratospher <44024636+stratospher@users.noreply.github.com>2023-01-29 23:54:43 +0530
committerstratospher <44024636+stratospher@users.noreply.github.com>2023-09-19 22:38:56 +0530
commit28bac81a346c0b68273fa73af924f7096cb3f41d (patch)
tree2cc392c2fe6c08024059d2e81bc47c00551cb847 /test
parentc8eb8dae51039aa1938e7040001a149210e87275 (diff)
downloadbitcoin-28bac81a346c0b68273fa73af924f7096cb3f41d.tar.xz
test: add functional test for getaddrmaninfo
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_net.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 255f5108a2..4fbe22a846 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -66,6 +66,7 @@ class NetTest(BitcoinTestFramework):
self.test_getnodeaddresses()
self.test_addpeeraddress()
self.test_sendmsgtopeer()
+ self.test_getaddrmaninfo()
def test_connection_count(self):
self.log.info("Test getconnectioncount")
@@ -360,6 +361,28 @@ class NetTest(BitcoinTestFramework):
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()