aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-07-23 16:21:14 +0100
committerJohn Newbery <john@johnnewbery.com>2020-08-12 09:22:10 +0100
commitae8051bbd8377f2458ff1f167dc30c2d5f83e317 (patch)
treefec2c63e88f2c3ab8c8d94ec0124c69314722849 /test
parentf26502e9fc8a669b30717525597e3f468eaecf79 (diff)
[test] Test that getnodeaddresses() can return all known addresses
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_net.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 3336246c8b..6173e658b0 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -168,16 +168,24 @@ class NetTest(BitcoinTestFramework):
msg.addrs.append(addr)
self.nodes[0].p2p.send_and_ping(msg)
- # obtain addresses via rpc call and check they were ones sent in before
- REQUEST_COUNT = 10
- node_addresses = self.nodes[0].getnodeaddresses(REQUEST_COUNT)
- assert_equal(len(node_addresses), REQUEST_COUNT)
+ # Obtain addresses via rpc call and check they were ones sent in before.
+ #
+ # All addresses added above are in the same netgroup and so are assigned
+ # to the same bucket. Maximum possible addresses in addrman is therefore
+ # 64, although actual number will usually be slightly less due to
+ # BucketPosition collisions.
+ node_addresses = self.nodes[0].getnodeaddresses(0)
+ assert_greater_than(len(node_addresses), 50)
+ assert_greater_than(65, len(node_addresses))
for a in node_addresses:
- assert_greater_than(a["time"], 1527811200) # 1st June 2018
+ assert_greater_than(a["time"], 1527811200) # 1st June 2018
assert_equal(a["services"], NODE_NETWORK | NODE_WITNESS)
assert a["address"] in imported_addrs
assert_equal(a["port"], 8333)
+ node_addresses = self.nodes[0].getnodeaddresses(1)
+ assert_equal(len(node_addresses), 1)
+
assert_raises_rpc_error(-8, "Address count out of range", self.nodes[0].getnodeaddresses, -1)
# addrman's size cannot be known reliably after insertion, as hash collisions may occur