@@ -168,16 +168,24 @@ def _test_getnodeaddresses(self):
168
168
msg .addrs .append (addr )
169
169
self .nodes [0 ].p2p .send_and_ping (msg )
170
170
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 ))
175
180
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
177
182
assert_equal (a ["services" ], NODE_NETWORK | NODE_WITNESS )
178
183
assert a ["address" ] in imported_addrs
179
184
assert_equal (a ["port" ], 8333 )
180
185
186
+ node_addresses = self .nodes [0 ].getnodeaddresses (1 )
187
+ assert_equal (len (node_addresses ), 1 )
188
+
181
189
assert_raises_rpc_error (- 8 , "Address count out of range" , self .nodes [0 ].getnodeaddresses , - 1 )
182
190
183
191
# addrman's size cannot be known reliably after insertion, as hash collisions may occur
0 commit comments