Skip to content

Commit ae8051b

Browse files
committed
[test] Test that getnodeaddresses() can return all known addresses
1 parent f26502e commit ae8051b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/functional/rpc_net.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,24 @@ def _test_getnodeaddresses(self):
168168
msg.addrs.append(addr)
169169
self.nodes[0].p2p.send_and_ping(msg)
170170

171-
# obtain addresses via rpc call and check they were ones sent in before
172-
REQUEST_COUNT = 10
173-
node_addresses = self.nodes[0].getnodeaddresses(REQUEST_COUNT)
174-
assert_equal(len(node_addresses), REQUEST_COUNT)
171+
# Obtain addresses via rpc call and check they were ones sent in before.
172+
#
173+
# All addresses added above are in the same netgroup and so are assigned
174+
# to the same bucket. Maximum possible addresses in addrman is therefore
175+
# 64, although actual number will usually be slightly less due to
176+
# BucketPosition collisions.
177+
node_addresses = self.nodes[0].getnodeaddresses(0)
178+
assert_greater_than(len(node_addresses), 50)
179+
assert_greater_than(65, len(node_addresses))
175180
for a in node_addresses:
176-
assert_greater_than(a["time"], 1527811200) # 1st June 2018
181+
assert_greater_than(a["time"], 1527811200) # 1st June 2018
177182
assert_equal(a["services"], NODE_NETWORK | NODE_WITNESS)
178183
assert a["address"] in imported_addrs
179184
assert_equal(a["port"], 8333)
180185

186+
node_addresses = self.nodes[0].getnodeaddresses(1)
187+
assert_equal(len(node_addresses), 1)
188+
181189
assert_raises_rpc_error(-8, "Address count out of range", self.nodes[0].getnodeaddresses, -1)
182190

183191
# addrman's size cannot be known reliably after insertion, as hash collisions may occur

0 commit comments

Comments
 (0)