mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
test: add functional test for getaddrmaninfo
This commit is contained in:
parent
c8eb8dae51
commit
28bac81a34
1 changed files with 23 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue