Skip to content

Commit

Permalink
[test] Test that getnodeaddresses() can return all known addresses
Browse files Browse the repository at this point in the history
Summary:
This is a backport of [[bitcoin/bitcoin#19658 | core#19658]] [2/3]
bitcoin/bitcoin@ae8051b

Depends on D10069

Test Plan: `ninja check-functional`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10070
  • Loading branch information
jnewbery authored and PiRK committed Sep 8, 2021
1 parent df54009 commit 6d3b92d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/functional/rpc_net.py
Expand Up @@ -226,16 +226,24 @@ def test_getnodeaddresses(self):
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_equal(a["services"], NODE_NETWORK)
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)

Expand Down

0 comments on commit 6d3b92d

Please sign in to comment.